home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / mskrmsrc.zip / MSSSET.ASM < prev    next >
Assembly Source File  |  1991-10-24  |  94KB  |  3,064 lines

  1.     NAME    mssset
  2. ; File MSSSET.ASM
  3.     include mssdef.h
  4. ;       Copyright (C) 1982,1991, Trustees of Columbia University in the
  5. ;       City of New York.  Permission is granted to any individual or
  6. ;       institution to use, copy, or redistribute this software as long as
  7. ;       it is not sold for profit and this copyright notice is retained.
  8. ; edit history:
  9. ; 6 Sept 1991 version 3.11
  10. ; Last edit 13 Aug 1991
  11.  
  12.     public setcom, prmptr, dodef, setcpt, docom, stkadr, rdbuf
  13.     public setrx, rxtable, srvdsa, srvena, mcctab, takopen, takclos, ask
  14.     public askq, assign, initibm, mccptr, setinpbuf, setrollb, npages
  15.     public xfchtab, xftyptab, com1port, com2port, com3port, com4port,
  16.     public    flotab, popcmd, domacptr, warntab, portirq, dodecom
  17.     public    tcpdata, tcphost
  18.  
  19. braceop    equ    7bh        ; opening curly brace
  20. bracecl    equ    7dh        ; closing curly brace
  21.  
  22. maketab    MACRO            ; Assembler Macro to make rxtable [jrd]
  23. cnt = 0
  24.     rept 256
  25.     db    cnt        ; initialize table to 0 .. 255
  26. cnt = cnt + 1
  27.     endm
  28.     db    0        ; table off (0) or on (1) indicator
  29. ENDM
  30.  
  31. data     segment
  32.     extrn    comand:byte, flags:byte, trans:byte, takadr:word, taklev:byte
  33.     extrn    portval:word, dtrans:byte, spause:byte, machnam:byte
  34.     extrn    filtst:byte, maxtry:byte, script:byte, denyflg:word
  35.     extrn    sloghnd:word, ploghnd:word, tloghnd:word
  36.     extrn    decbuf:byte, kstatus:word, errlev:byte, srvtmo:byte
  37.     extrn    luser:byte, lpass:byte, partab:byte, destab:byte, blktab:byte
  38.     extrn    seoftab:byte, dmpname:byte, lsesnam:byte, lpktnam:byte
  39.     extrn    ltranam:byte, incstb:byte, inactb:byte, rxoffmsg:byte
  40.     extrn    rxonmsg:byte, scpbuflen:word, oldtak:byte, setchtab:byte
  41.     extrn    prnname:byte, prnhand:word
  42.  
  43. rxtable    equ THIS BYTE        ; build 256 byte Translation Input table
  44.     maketab            ; table rxtable is used by Connect mode
  45.  
  46. kerm    db    'MS-Kermit>',0        ; default asciiz prompt
  47. prm    db    60 dup (0)        ; buffer for new prompt
  48. rdbuf    db    cmdblen dup (?)        ; work space; room for macro def
  49.                     ;  and for Status display line
  50.  
  51. stflg    db    0        ; Says if setting SEND or RECEIVE parameter
  52. defkind    db    0        ; 0 for ASSIGN, 1 for DEFINE
  53. ermes1    db    cr,lf,'?Too many macro names$'
  54. ermes2    db    cr,lf,bell,'?No room for Take file buffer or Macro definition'
  55.     db    cr,lf,bell,'$'
  56. ermes4    db    cr,lf,'?Too many active Take files and Macros',cr,lf, bell,'$'
  57. ermes5    db    cr,lf,'?Not implemented$'
  58. ermes6    db    cr,lf,'?More parameters are needed$'
  59. ermes7    db    cr,lf,'?Cannot use RTS/CTS on non-UART ports$'
  60. errcap    db    cr,lf,'?Unable to open that file$'
  61. erropn    db    cr,lf,'?Log file is already open$'
  62. askhlp1    db    'Variable name  then  prompt string$'
  63. askhlp2    db    'Prompt string$'
  64. askhlp3    db    'Enter a line of text$'
  65. filhlp    db    ' Output filename for the log$'
  66. dishlp    db    cr,lf,' Quiet (no screen writing), Regular (normal),'
  67.     db    ' Serial (non-formatted screen)'
  68.     db    cr,lf,' and/or 7-BIT (default) or 8-BIT wide characters.$'
  69. remhlp    db    cr,lf,' OFF to show file transfer display,'
  70.     db    ' ON for quiet screen$'
  71. macmsg    db    ' Specify macro name followed by body of macro, on same line$'
  72. prmmsg    db    cr,lf
  73.     db    ' Enter new prompt string or nothing to regain regular prompt.'
  74.     db    cr,lf,' Use \123 notation for special chars (Escape is \27)$'
  75.  
  76. srxhlp1    db    cr,lf,' Enter   code for received byte   code for'
  77.     db    ' local byte ',cr,lf,' use ascii characters themselves or'
  78.     db    cr,lf,' numerical equivalents of  \nnn  decimal'
  79.     db    ' or \Onnn  octal or \Xnnn  hexadecimal',cr,lf
  80.     db    ' or keywords  ON  or  OFF  (translation is initially off)'
  81.     db    cr,lf,'$'
  82. badrx    db    cr,lf,'?Expected ON, OFF, or \nnn$'
  83.  
  84. takchlp    db    cr,lf,'Value 0 to 65535 for COUNT in script IF COUNT command$'
  85. takcerr    db    cr,lf,'?Note: command is valid only in Take files and Macros$'
  86.  
  87. dmpdefnam db    'Kermit.scn',0        ; asciiz default screen dump filename
  88. prndefnam db    'PRN',0            ; asciiz default printer name
  89. nummsg1 db    cr,lf,'?Use a number between $'
  90. nummsg2    db    ' and $'
  91. srvthlp    db    'seconds, 0-255, waiting for a transaction$'
  92. unkchhlp db    cr,lf,' Disposition of files arriving with unknown'
  93.     db    ' character sets:',cr,lf,'  Keep (default), Cancel$'
  94. winhelp    db    cr,lf,'Number of sliding window slots 1 (no windowing) to 31.'
  95.     db    cr,lf,'This also subdivides the 2000 byte main packet buffer'
  96.     db    cr,lf,'and may reduce the Send and Receive packet lengths.$'
  97. ctlhlp    db    ' Decimal number between 0 and 31$'
  98. dmphlp    db    ' Filename to hold screen dumps$'
  99. prnhlp    db    ' Filename for printer output (default is PRN)$'
  100. prnerr    db    cr,lf,' Cannot open that name. Using default of PRN$'
  101. erlhlp    db    ' Decimal number between 0 and 255$'
  102. pakerr    db    cr,lf,'?Choose a decimal number '
  103.     db    'from 20 to 94 (normal) or to 2000 (long)$'
  104. pakhlp    db    cr,lf,'Decimal number between 20 and 94 (normal) or '
  105.     db    '2000 (long)$'
  106. padhlp    db    cr,lf,' Decimal number between 0 and 31 or 127$'
  107. pauhlp    db    ' Decimal number between 0 and 127$'
  108. quohlp    db    ' Decimal number between 33 and 126$'
  109. retryhlp db    ' Decimal number between 1 and 63$'
  110. dblhlp    db    ' Decimal number between 0 and 255$'
  111. luserh    db    cr,lf,'Username Password from remote Kermit (0-16 chars each)$'
  112. lpassh    db    cr,lf,'Password from remote Kermit (0-16 chars,'
  113.     db    ' spaces allowed)$'
  114. timhlp    db    ' Decimal number between 0 and 94$'
  115. delyhlp    db    ' Delay seconds before sending file (0-63)$'
  116. eschlp    db    cr,lf,'Press literal control keys (ex: Control ]) or'
  117.     db    ' enter in \nnn numerical form$'
  118. escerr    db    cr,lf,'?Not a control code$'
  119. hnd1hlp    db    cr,lf,'XON (\17), XOFF (\19), CR (\13), LF (\10), BELL (\7),'
  120.     DB    ' ESC (\27), NONE (\0)'
  121.     db    cr,lf,' or "CODE" followed by decimal number$' 
  122. intoms    db    'number of seconds to wait before timeout',cr,lf,'$'
  123. loghlp    db    cr,lf
  124.     db    ' PACKETS - during file transfers  (to default file PACKET.LOG)'
  125.     db    cr,lf
  126.     db    ' SESSION - during Connect mode   (to default file SESSION.LOG)'
  127.     db    cr,lf
  128.     db    ' TRANSACTIONS - files transfers (to default file TRANSACT.LOG)'
  129.     db    cr,lf,'  followed by an optional filename for the log.$'
  130. comhlp    db    cr,lf,' Address of the COM1 - COM4 port (ex: COM3 \x02f8 or'
  131.     db    ' COM4 \x02e8)$'
  132. irqhlp    db    cr,lf,' Enter, or IRQ of port (ex: \3)$'
  133. debhlp    db    cr,lf,' PACKETS - during file transfers'    ; Debugging
  134.     db    cr,lf,' SESSION - during Connect mode'
  135.     db    cr,lf,' ON - both packets and session'
  136.     db    cr,lf,' OFF - turns off all debugging$'
  137. dohlp    db    cr,lf,'definitions of variables (\%n), or press ENTER key$'
  138.  
  139. sdshlp    db    cr,lf,'DISABLE or ENABLE access to selected Server commands:'
  140.     db    cr,lf
  141.     db    ' CD/CWD, DEL, DIR, FINISH (includes BYE & LOGOUT), GET,'
  142.     db    ' HOST, KERMIT, LOGIN,',cr,lf
  143.     db    ' PRINT, SEND, SPACE, TYPE, and ALL.$'
  144.  
  145. xfchhlp    db    cr,lf,' Which character set to put on the wire during file'
  146.     db    ' transfers:',cr,lf
  147.     db    '  TRANSPARENT (regular PC codes)',cr,lf
  148.     db    '  LATIN1   (ISO 8859-1)',cr,lf
  149.     db    '  CYRILLIC (ISO 8859-5)$'
  150. xfchbad    db    cr,lf,'Warning: forcing SET FILE CHARACTER-SET of CP866$'
  151. setchmsg db   cr,lf,'Warning: forcing SET TRANSFER CHARACTER-SET of CYRILLIC$'
  152. xfilhlp    db    'NONE, SPACE, or filler character$'
  153. xpmthlp db    'Host echo char acting as prompt, \1-\255$'
  154. pophlp    db    'Status value to be returned, nothing if no new value$'
  155. crlf    db    cr,lf,'$'
  156.  
  157. srvtab    db    2            ; SET SERVER table
  158.     mkeyw    'Login',1
  159.     mkeyw    'Timeout',2
  160.  
  161. sethlp    db    cr,lf
  162.     db    '  Alarm    sec from now or HH:MM:SS  '
  163.     db    '  Log kind  opt filename'
  164.     db    cr,lf
  165.     db    '  Attributes packets on/off          '
  166.     db    '  Mode-line         on/off'
  167.     db    cr,lf
  168.     db    '  Bell    on/off    at end of xfers  '
  169.     db    '  NetBios-name      (our local name)'
  170.     db    cr,lf
  171.     db    '  Block-check-type  checksum/CRC     '
  172.     db    '  Parity    even/odd/mark/space/none'
  173.     db    cr,lf
  174.     db    '  COM1 - COM4 address                '
  175.     db    '  Port for i/o      1/2/COM1/COM2/etc'
  176.     db    cr,lf
  177.     db    '  COUNT   number    a loop counter   '
  178.     db    '  Printer filespec   for Connect mode'
  179.     db    cr,lf
  180.     db    '  Debug   on/off    display packets  '
  181.     db    '  Prompt  string   (new Kermit prompt)'
  182.     db    cr,lf
  183.     db    '  Default-disk                       '
  184.     db    '  Receive parameter  many things'
  185.     db    cr,lf
  186.     db    '  Delay   secs  before Sending file  '
  187.     db    '  Remote    on/off  show xfer counts?'
  188.     db    cr,lf
  189.     db    '  Destination   Disk/Screen/Printer  '
  190.     db    '  Retry limit for packet send/receive'
  191.     db    cr,lf
  192.     db    '  Display quiet/reg/serial show cnts?'
  193.     db    '  Send parameter    many things'
  194.     db    cr,lf
  195.     db    '  Dump filespec     screen to disk   '
  196.     db    '  Server parameter'
  197.     db    cr,lf
  198.     db    '  Duplex            half or full     '
  199.     db      '  Speed or Baud     many speeds'    
  200.     db    cr,lf
  201.     db    '  EOF Ctrl-Z/NoCtrl-Z  ^Z ends file? '
  202.     db    '  Take-echo on/off  display commands?' 
  203.     db    cr,lf
  204.     db     '  End-of-line char  cr or whatever   '
  205.     db    '  Terminal none/H-19/VT52/VT102/VT320'
  206.     db    cr,lf
  207.     db    '  Errorlevel number   for DOS Batch  '
  208.     db    '     and many terminal setup parameters'
  209.     db    cr,lf
  210.     db      '  Escape char  ^]   or whatever      '
  211.     db    '  TCP/IP address,mask,nameserver etc'
  212.     db    cr,lf
  213.     db    '  File (Character-set, Type, Warning)'
  214.     db    '  Timer     on/off  time packet waiting'
  215.     db    cr,lf
  216.     db    '  Flow-control  NONE XON/XOFF RTS/CTS'
  217.     db    '  Translation IN  Connect mode rcv''d char'
  218.     db    cr,lf
  219.     db    '  Handshake xon/xoff/cr/lf/bell/esc..'
  220.     db    '  Transfer Character-set (on wire) '
  221.     db    cr,lf
  222.     db    '  Incomplete file   keep/discard     '
  223.     db    '  Transmit  parameters, for scripts'
  224.     db    cr,lf
  225.     db    '  Input timeout, etc  (for scripts)  '
  226.     db    '  Unknown-character-set (keep/cancel)'
  227.     db    cr,lf
  228.     db    '  Key         key-ident   definition '
  229.     db    '  Warning   on/off  if file renamed'
  230.     db    cr,lf
  231.     db    '  Local-echo        on/off           '
  232.     db    '  Windows  number of sliding window slots'
  233.     db    '$'
  234.  
  235. settab     db    51                    ; Set table
  236.     mkeyw    'Alarm',setalrm
  237.     mkeyw    'Attributes',setatt
  238.     mkeyw    'Baud',baudst
  239.     mkeyw    'Bell',bellst
  240.     mkeyw    'Block-check-type',blkset
  241.     mkeyw    'COM1',com1port
  242.     mkeyw    'COM2',com2port
  243.     mkeyw    'COM3',com3port
  244.     mkeyw    'COM4',com4port
  245.     mkeyw    'Count',takectr
  246.     mkeyw    'Debug',debst
  247.     mkeyw    'Default-disk',cwdir
  248.     mkeyw    'Delay',setdely
  249.     mkeyw    'Destination',desset
  250.     mkeyw    'Display',disply
  251.     mkeyw    'Dump',setdmp
  252.     mkeyw    'Duplex',setdup
  253.     mkeyw    'End-of-Line',eolset
  254.     mkeyw    'EOF',seteof
  255.     mkeyw    'Errorlevel',seterl
  256.     mkeyw    'Escape',escset
  257.     mkeyw    'File',setfile
  258.     mkeyw    'Flow-control',floset
  259.     mkeyw    'Handshake',hndset
  260.     mkeyw    'Incomplete',abfset
  261.     mkeyw    'Input',inpset
  262.     mkeyw    'Key',setkey
  263.     mkeyw    'Local-echo',lcal
  264.     mkeyw    'Log',setcpt            ; same as log command
  265.     mkeyw    'Mode-line',modl
  266.     mkeyw    'NetBios-name',setnbios
  267.     mkeyw    'Parity',setpar
  268.     mkeyw    'Port',coms
  269.     mkeyw    'Printer',setprn
  270.     mkeyw    'Prompt',promset
  271.     mkeyw    'Receive',recset
  272.     mkeyw    'Remote',remset
  273.     mkeyw    'Retry',retryset
  274.     mkeyw    'Send',sendset
  275.     mkeyw    'Server',setsrv
  276.     mkeyw    'Speed',baudst
  277.     mkeyw    'Take-echo',takset
  278.     mkeyw    'TCP/IP',tcpipset
  279.     mkeyw    'Terminal',vts
  280.     mkeyw    'Timer',timset
  281.     mkeyw    'Transfer',sxfer
  282.     mkeyw    'Translation',setrx
  283.     mkeyw    'Transmit',setxmit
  284.     mkeyw    'Unknown-character-set',unkchset
  285.     mkeyw    'Warning',filwar
  286.     mkeyw    'Windows',winset
  287.  
  288. setfitab db    5            ; Set File command table
  289.     mkeyw    'Character-Set',1
  290.     mkeyw    'Collision',0
  291.     mkeyw    'Display',3
  292.     mkeyw    'Type',2
  293.     mkeyw    'Warning (Collision)',0
  294.  
  295. xfertab    db    1            ; SET TRANSFER table
  296.     mkeyw    'Character-set',0
  297.  
  298. xfchtab    db    3            ; SET TRANSFER CHARACTER-SET
  299.     mkeyw    'TRANSPARENT',0        ; no translation
  300.     mkeyw    'Latin1 ISO 8859-1',1    ; ISO 8859-1, Latin-1
  301.     mkeyw    'Cyrillic ISO 8859-5',2    ; ISO 8859-5/Cyrillic, CP866
  302.  
  303. xftyptab db    2            ; SET FILE TYPE table
  304.     mkeyw    'Binary',1        ; Binary = as-is
  305.     mkeyw    'Text',0        ; Text = can change char sets
  306.  
  307. warntab    db    6            ; File Warning table
  308.     mkeyw    'Overwrite',1        ; overwrite
  309.     mkeyw    'Rename',0        ; rename
  310.     mkeyw    'Discard',4         ; discard
  311.     mkeyw    'No-supersede',4    ; discard
  312.     mkeyw    'on (rename)',0        ; old form
  313.     mkeyw    'off (overwrite)',1    ; old form
  314.  
  315. unkctab db    2            ; unknown character-set disposition
  316.     mkeyw    'Keep',0
  317.     mkeyw    'Cancel',1
  318.  
  319. atttab    db    6            ; SET ATTRIBUTES table
  320.     mkeyw    'Off',00ffh        ; all off
  321.     mkeyw    'On',10ffh        ; all on (high byte is on/off)
  322.     mkeyw    'Character-set',attchr    ; Character set
  323.     mkeyw    'Date-Time',attdate    ; Date and Time
  324.     mkeyw    'Length',attlen        ; Length
  325.     mkeyw    'Type',atttype        ; Type
  326.  
  327. comtab    db    2            ; table of COM ports
  328.     mkeyw    'COM3',4        ; offset of COM3 address
  329.     mkeyw    'COM4',6        ; offset of COM4 address
  330.  
  331. stsrtb    db    10                ; Number of options
  332.     mkeyw    'Packet-length',srpack
  333.     mkeyw    'Padchar',srpad
  334.     mkeyw    'Padding',srnpd
  335.     mkeyw    'Pause',srpaus
  336.     mkeyw    'Start-of-packet',srsoh
  337.     mkeyw    'Quote',srquo
  338.     mkeyw    'End-of-packet',sreol
  339.     mkeyw    'Timeout',srtim
  340.     mkeyw    'Double-char',srdbl
  341.     mkeyw    'Ignore-char',srign
  342.  
  343. ontab    db    2
  344.     mkeyw    'off',0
  345.     mkeyw    'on',1
  346.  
  347. distab    db    5             ; Set Display mode
  348.     mkeyw    '7-bit',7        ; controls bit d8bit in flags.remflg
  349.     mkeyw    '8-bit',8        ; sets d8bit
  350.     mkeyw    'Quiet',dquiet        ; values defined in header file
  351.     mkeyw    'Regular',dregular
  352.     mkeyw    'Serial',dserial
  353.  
  354. distab2    db    3            ; for SET FILE DISPLAY
  355.     mkeyw    'Quiet',dquiet        ; values defined in header file
  356.     mkeyw    'Regular',dregular
  357.     mkeyw    'Serial',dserial
  358.  
  359. ; If abort when receiving files, can keep what we have or discard
  360. abftab    db    2
  361.     mkeyw    'Discard',1
  362.     mkeyw    'Keep',0
  363.  
  364. flotab    db    3
  365.     mkeyw    'none',0
  366.     mkeyw    'xon/xoff',1
  367.     mkeyw    'RTS/CTS',2
  368.  
  369. hndtab    db    8
  370.     mkeyw    'none',0
  371.     mkeyw    'bell',bell
  372.     mkeyw    'cr',cr
  373.     mkeyw    'esc',escape
  374.     mkeyw    'lf',lf
  375.     mkeyw    'xoff',xoff
  376.     mkeyw    'xon',xon
  377.     mkeyw    'code',0ffh        ; allow general numerial code
  378.  
  379. duptab    db    2            ; SET DUPLEX table
  380.     mkeyw    'full',0
  381.     mkeyw    'half',1
  382.  
  383. inptab    db    4                ; Scripts. Set Input
  384.     mkeyw    'Case',inpcas            ;[jrs]
  385.     mkeyw    'Default-timeout',inptmo    ;[jrs]
  386.     mkeyw    'Echo',inpeco            ;[jrs]
  387.     mkeyw    'Timeout-action',inpact        ;[jrs]
  388.  
  389. xmitab    db    3            ; SET TRANSMIT table
  390.     mkeyw    'Fill-empty-line',0
  391.     mkeyw    'Line-Feeds-sent',1
  392.     mkeyw    'Prompt',2
  393.  
  394. debtab    db    4            ; Set Debug command
  395.     mkeyw    'Off',0
  396.     mkeyw    'On',logpkt+logses
  397.     mkeyw    'Packets',logpkt
  398.     mkeyw    'Session',logses
  399.  
  400. logtab    db    3            ; LOG command
  401.     mkeyw    'Packets',logpkt
  402.     mkeyw    'Session',logses
  403.     mkeyw    'Transactions',logtrn
  404.  
  405. srvdetab db    14            ; Server Enable/Disable list
  406.     mkeyw    'All',0fffh
  407.     mkeyw    'CD',cwdflg
  408.     mkeyw    'CWD',cwdflg
  409.     mkeyw    'Delete',delflg
  410.     mkeyw    'Dir',dirflg
  411.     mkeyw    'Finish',finflg
  412.     mkeyw    'Get',getsflg
  413.     mkeyw    'Host',hostflg
  414.     mkeyw    'Kermit',kerflg
  415.     mkeyw    'Login',pasflg
  416.     mkeyw    'Print',prtflg
  417.     mkeyw    'Send',sndflg
  418.     mkeyw    'Space',spcflg
  419.     mkeyw    'Type',typflg
  420.  
  421. trnstab    db    2            ; Set Translation table
  422.     mkeyw    'Input',1
  423.     mkeyw    'Keyboard',2
  424.  
  425. tcptable db    8            ; TCP/IP command
  426.     mkeyw    'address',1        ; local Internet address
  427.     mkeyw    'domain',2        ; local domain string
  428.     mkeyw    'broadcast',8        ; broadcast of all 0's or all 1's
  429.     mkeyw    'gateway',4        ; gateway address
  430.     mkeyw    'primary-nameserver',5    ; address
  431.     mkeyw    'secondary-nameserver',6
  432.     mkeyw    'subnetmask',3        ; our subnet mask
  433.     mkeyw    'host',7        ; host's IP name or IP number
  434.  
  435. hosthlp    db    cr,lf,'Internet name or number (ddd.ddd.ddd.ddd) of '
  436.     db    'the remote machine$'
  437. domainhlp db    cr,lf,'Name of your domain$'
  438. subnethlp db    cr,lf,'Subnetmask, decimal ddd.ddd.ddd.ddd$'
  439. addrhelp db    cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd, of this'
  440.     db    ' machine or BOOTP or RARP$'
  441. iphelp    db    cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd$'
  442. domainbad db    cr,lf,'?Bad domain name, use is such as my.domain.name$'
  443. addressbad db    cr,lf,'?Bad Internet address, string is too long$'
  444. hostbad    db    cr,lf,'?Bad host, use IP name or IP number$'
  445.  
  446. tcpaddress db    'unknown',(32-($-tcpaddress)) dup (0),0
  447. tcpsubnet  db    '255.255.255.0',(32-($-tcpsubnet)) dup (0),0
  448. tcpdomain  db    'unknown',(32-($-tcpdomain)) dup (0),0
  449. tcpgateway db    'unknown',(32-($-tcpgateway)) dup (0),0
  450. tcpprimens db    'unknown',(32-($-tcpprimens)) dup (0),0
  451. tcpsecondns db    'unknown',(32-($-tcpsecondns)) dup (0),0
  452. tcphost    db    (32 -($-tcphost)) dup (0),0
  453. tcpbcast db    '255.255.255.255',(32-($-tcpbcast)) dup (0),0
  454.  
  455. tcpdata    dw    offset tcpaddress    ; externally visible far pointers
  456.     dw    offset tcpsubnet
  457.     dw    offset tcpdomain
  458.     dw    offset tcpgateway
  459.     dw    offset tcpprimens
  460.     dw    offset tcpsecondns
  461.     dw    offset tcphost
  462.     dw    offset tcpbcast
  463.  
  464. ; MACRO DATA STRUCTURES mcctab
  465. mcclen    equ    macmax*10        ; length of mcctab
  466. mcctab    db    0            ; macro name table entries
  467.     db    mcclen dup (0)        ; room for macro structures
  468. ; END OF MACRO DATA STRUCTURES
  469.  
  470. ibmmac    db    'IBM '            ; startup IBM macro definition + space
  471.     db    'set timer on,set parity mark,set local-echo on,'
  472.     db    'set handshake xon,set flow none,',0    ; asciiz
  473.  
  474.     even
  475. prmptr    dw    kerm            ; pointer to prompt
  476. tempptr    dw    0            ; pointer into work buffer
  477. domacptr dw    0            ; pointer to DO MAC string
  478. min    dw    0 
  479. max    dw    0 
  480. numerr    dw    0
  481. numhlp    dw    0
  482. temp    dw    0
  483. temp1    dw    0            ; Temporary storage
  484. temp2    dw    0            ; Temporary storage
  485. askecho db    0            ; ask's echo control flag
  486. temptc    db    3,0,0,'T',0,0        ; temp, for takclos, word cnt,<null>T#
  487. deftemp    dw    0
  488. stkadr    dw    0    ; non-zero if replacement keyboard xlator present
  489. mccptr    dw    mcctab             ; ptr to first free byte in mcctab
  490. macptr    dw    0            ; temp to hold segment of string
  491. npages    dw    10             ; # of pages of scrolling on each side
  492. portirq    db    4 dup (0)        ; user specified IRQ's for COM1..4
  493.  
  494. data    ends
  495.  
  496. code1    segment
  497.     extrn    makebuf:far
  498. code1    ends
  499.  
  500. code    segment
  501.     extrn comnd:near, baudst:near, prompt:near, coms:near, cwdir:near
  502.     extrn isfile:near, strlen:near, strcpy:near, cnvlin:near
  503.     extrn katoi:near, decout:near, vts:near, setalrm:near, serrst:near
  504.     extrn prnopen:near, pntflsh:near
  505.     extrn setnbios:near    ; in MSXIBM, needs stub for other machines
  506.  
  507.     assume    cs:code, ds:data, es:nothing
  508.  
  509. ; DO defined macro command
  510. ; DO macname variable variable   also defines variables \%1, \%2, ...\%9
  511. DOCOM    PROC    NEAR
  512.     mov    dx,offset mcctab    ; table of macro defs
  513.     xor    bx,bx            ; help is table
  514.     mov    ah,cmkey        ; get key word (macro name)
  515.     call    comnd            ; get pointer to keyword structure
  516.     jnc    docom1            ; nc = success, bx = 16 bit data
  517.     ret                ; failure
  518. docom1:    mov    domacptr,bx        ; segment of definition string
  519.     mov    comand.cmquiet,0    ; permit command echoing
  520.     mov    bx,offset decbuf    ; point to borrowed work buffer
  521.     mov    word ptr[bx],0        ; clear buffer
  522.     mov    dx,offset dohlp        ; help
  523.     mov    comand.cmblen,length rdbuf ; length of analysis buffer
  524.     mov    ah,cmline        ; get line of text, if any
  525.     call    comnd
  526.     jnc    docom2            ; nc = success
  527.     ret                ; failure
  528. docom2:    mov    deftemp,ax        ; save byte count of command args
  529.     call    hidemac            ; hide previous \%0..\%9 macros
  530.     call    getname            ; get name of this macro
  531.     mov    cx,word ptr rdbuf    ; length of "\%0 plus found name"
  532.     call    dodecom            ; add keyword+def using DEF MAC below
  533.     jnc    docom2a            ; nc = success
  534.     ret
  535. docom2a:call    docnv            ; convert macro string
  536.     jnc    docom2b            ; nc = success
  537.     ret
  538. docom2b:mov    max,1            ; temp for counting 1 + number args
  539.     mov    word ptr rdbuf+4,' 1'    ; number of first variable
  540. docom3:    mov    word ptr rdbuf,0    ; clear length field, install \%x name
  541.     mov    word ptr rdbuf+2,'%\'    ; start with '\%1 '
  542.     mov    word ptr rdbuf+6,0    ; clear text field
  543.     mov    tempptr,offset rdbuf+6    ; pointer to location of found word
  544.     xor    ch,ch            ; make cx = 1 - 9
  545.     mov    cl,rdbuf+4        ; cx = word # of interest, for getwrd
  546.     sub    cl,'0'            ; remove ascii bias
  547.     mov    si,offset decbuf    ; source = work buffer (borrowed)
  548.     call    getwrd            ; get CX-th word from  work buf (1-9)
  549.     cmp    deftemp,0        ; length of word, was it found?
  550.     je    docom4            ; e = no, end variable definition part
  551.     add    deftemp,4        ; count '\%n ' in command line length
  552.     inc    max            ; one more argument
  553.     mov    cx,deftemp        ; command length for dodecom
  554.     call    dodecom            ; add keyword+def using DEF MAC below
  555.     jnc    docom3a
  556.     ret                ; failure
  557. docom3a:inc    rdbuf+4            ; inc number of variable in '\%n '
  558.     cmp    rdbuf+4,'9'
  559.     jbe    docom3            ; do '1' through '9', if available
  560.  
  561.                     ; DO the macro itself
  562. docom4:    cmp    taklev,maxtak        ; room in take level?
  563.     jl    docom5            ; l = yes, continue
  564.     mov    dx,offset ermes4    ; else complain
  565.     jmp    reterr
  566. docom5:    inc    taklev            ; increment take level
  567.     add    takadr,size takinfo    ; create a Take macro
  568.     mov    bx,takadr        ; point to current structure
  569.     push    es
  570.     mov    es,domacptr        ; segment of macro definition string
  571.     mov    [bx].takbuf,es        ; remember in Take structure
  572.     mov    cx,es:word ptr [0]    ; length of definition string
  573.     pop    es
  574.     mov    [bx].takcnt,cx        ; # of chars in buffer
  575.     mov    [bx].taktyp,0ffh    ; flag as a macro
  576.     mov    [bx].takptr,2        ; point to beginning of def text
  577.     mov    cx,max            ; 1 + number of arguments
  578.     mov    [bx].takargc,cx
  579.     clc                ; success
  580.     ret
  581. DOCOM    ENDP
  582.  
  583. ; Create a new macro, named <0>T<taklev digit>, with the command line of the
  584. ; original macro modified to replace bare commas with Carriage Returns.
  585. ; Enter with domacptr pointing at the segment of the macro's definition.
  586. ; Return with domacptr pointing at the new buffer created by dodecom.
  587. docnv    proc    near
  588.     cmp    taklev,maxtak        ; room in take level?
  589.     jb    docnv1            ; b = yes
  590.     mov    dx,offset ermes4    ; say too many Take files
  591.     mov    ah,prstr        ; display error message
  592.     int    dos
  593.     stc                ; set carry for failure
  594.     ret
  595.  
  596. docnv1:    push    es
  597.     mov    word ptr rdbuf,3    ; length of name, 3 bytes <null>Tn
  598.     mov    rdbuf+2,0
  599.     mov    rdbuf+3,'T'        ; name of <null>Tn
  600.     mov    al,taklev        ; Take level digit
  601.     inc    al            ; for what will be next Take level
  602.     add    al,'0'            ; add ascii bias
  603.     mov    rdbuf+4,al        ; last of the name
  604.     mov    rdbuf+5,' '        ; separate dummy definition
  605.     mov    ax,domacptr
  606.     mov    es,ax            ; seg of definition
  607.     xor    si,si            ; offset of definition
  608.     mov    di,offset rdbuf+6    ; destination
  609.     mov    cx,es:[si]        ; read count of string
  610.     add    si,2            ; point at string itself
  611.     xor    bl,bl            ; brace count
  612.     mov    dl,braceop        ; opening brace (we count them up)
  613.     mov    dh,bracecl        ; closing brace (we count them down)
  614.     xor    bp,bp            ; offset of last closing brace+1
  615.     cmp    es:[si],dl        ; starts with opening brace?
  616.     jne    docnv2            ; ne = no
  617.     inc    si            ; skip this new leading space
  618.     dec    cx            ; and don't count it either
  619.     inc    bh            ; say opening brace was found
  620. docnv2:    mov    al,es:[si]        ; read a char
  621.     inc    si
  622.     cmp    al,dl            ; opening brace?
  623.     jne    docnv3            ; ne = no
  624.     inc    bl            ; count brace level
  625.     jmp    short docnv5
  626. docnv3:    cmp    al,dh            ; closing brace?
  627.     jne    docnv4            ; ne = no
  628.     dec    bl
  629.     or    bl,bl            ; below 0?
  630.     jg    docnv4            ; g = no, still in braces
  631.     jz    docnv5            ; matching interior braces
  632.     or    bh,bh            ; was there an opening brace?
  633.     jz    docnv5            ; z = no, record this one
  634.     xor    bx,bx            ; found opening match, reset to zero
  635.     jmp    short docnv6        ; omit the brace
  636. docnv4:    or    bl,bl            ; in braced clause?
  637.     jnz    docnv5            ; nz = yes, treat comma as literal
  638.     cmp    al,','            ; unbraced comma?
  639.     jne    docnv5            ; ne = no
  640.     mov    al,CR            ; replace bare comma with CR
  641. docnv5:    mov    [di],al
  642.     inc    di
  643. docnv6:    loop    docnv2
  644.     pop    es
  645.     cmp    byte ptr [di-1],cr    ; ends on a Carriage Return?
  646.     je    docnv7            ; e = yes
  647.     mov    byte ptr [di],cr    ; insert one to do sync execution
  648.     inc    di
  649. docnv7:    mov    byte ptr [di],0        ; null terminator, for safety
  650.     sub    di,offset rdbuf+2    ; start of string (skips count)
  651.     mov    cx,di            ; length of string
  652.     call    dodecom            ; define macro from rdbuf+2
  653.     mov    domacptr,ax        ; seg of new string
  654.     ret
  655. docnv    endp
  656.  
  657. ; Extract CX-th word (cx = 1-9) from buffer (DI). Enter with si = source
  658. ; string and tempptr pointing at destination. Returns deftemp (count) of
  659. ; transferred characters. Allow string in curly braces to exist as a word.
  660. ; Adjacent curly braced strings are separate "words":
  661. ;    {this is word-one}{this is word-two}word-three.
  662. ; First level curly braces are removed.
  663. ; All registers preserved.
  664. getwrd    proc    near
  665.     push    si
  666.     push    di
  667.     push    es
  668.     push    ds
  669.     pop    es            ; set es to data segment
  670. getwr1:    push    cx            ; save word counter (1-9)
  671.     mov    deftemp,0        ; no bytes transferred yet
  672.     mov    di,tempptr        ; where to store word/string
  673.     mov    byte ptr [di],0        ; clear destination
  674.     mov    dx,si            ; start looking here in work buf
  675.     call    strlen            ; cx = remaining length of work buf
  676.     jcxz    getwr6            ; z = nothing there, quit
  677. getwr2:    lodsb
  678.     cmp    al,' '            ; skip leading whitespace
  679.     loope    getwr2
  680.     dec    si            ; return to break char
  681.                     ; Parse curly brace delimited string
  682.                     ; end with si after closing brace
  683.     xor    dl,dl            ; assume "opening brace" is a null
  684.     mov    dh,' '            ; assume "closing brace" is a space
  685.     mov    cx,1            ; we are at brace level 1
  686.     cmp    byte ptr [si],braceop    ; starting with a real opening brace?
  687.     jne    getwr3            ; ne = no
  688.     inc    si            ; skip opening brace
  689.     dec    cx
  690.     mov    dl,braceop        ; opening brace (we count them up)
  691.     mov    dh,bracecl        ; closing brace (we count them down)
  692. getwr3:    cld                ; search forward
  693.     lodsb                ; read a char
  694.     stosb                ; store in output buffer
  695.     or    al,al            ; at end of text?
  696.     jnz    getwr3a            ; nz = no
  697.     dec    si            ; stay at null terminator
  698.     dec    di
  699.     jmp    short getwr6        ; we are done with this "word"
  700. getwr3a:inc    deftemp            ; count copied char
  701.     cmp    al,dl            ; an opening brace?
  702.     jne    getwr4            ; ne = no
  703.     inc    cx            ; yes, increment brace level
  704.     jmp    short getwr3        ;  and continue scanning
  705.  
  706. getwr4:    cmp    al,dh            ; closing brace?
  707.     jne    getwr3            ; ne = no, continue scanning
  708.     dec    cx            ; yes, decrement brace level
  709.     cmp    byte ptr [si],0        ; have we just read the last char?
  710.     jne    getwr5            ; no, continue scanning
  711.     xor    cx,cx            ; yes, this is the closing brace
  712. getwr5:    or    cx,cx            ; at level 0?
  713.     jg    getwr3            ; g = no, #opening <> #closing braces
  714.     dec    di            ; don't write closing brace
  715.     dec    deftemp            ; do not count closing brace
  716. getwr6:    pop    cx            ; recover word counter
  717.     mov    byte ptr [di],0
  718.     jcxz    getwrx            ; just in case
  719.     loop    getwr1            ; do until desired word is copied
  720. getwrx:    pop    es
  721.     pop    di
  722.     pop    si
  723.     ret
  724. getwrd    endp
  725.  
  726. ; Get macro name, given the action pointer in domacptr.
  727. ; Return rdbuf as word:length that follows, then "\%0 macro-name"
  728. getname proc    near
  729.     push    bx
  730.     push    cx
  731.     push    dx
  732.     push    si
  733.     push    di
  734.     mov    dx,domacptr        ; action word to be matched
  735.     mov    bx,offset mcctab+1    ; table of macro names, skip count
  736.     mov    word ptr rdbuf,4    ; name length and space
  737.     mov    word ptr rdbuf+2,'%\'    ; define '\%0 '
  738.     mov    word ptr rdbuf+4,' 0'
  739.     mov    cl,mcctab        ; number of entries
  740.     xor    ch,ch
  741.     jcxz    getnam3            ; z = empty table
  742. getnam1:push    cx
  743.     mov    cx,[bx]            ; length of name
  744.     mov    si,bx            ; point at structure member
  745.     add    si,2            ; plus count
  746.     add    si,cx            ; plus length of name
  747.     mov    ax,[si]            ; get action word
  748.     cmp    ax,dx            ; correct action word?
  749.     jne    getnam2            ; ne = no
  750.     push    es
  751.     push    ds
  752.     pop    es
  753.     add    word ptr rdbuf,cx    ; length of macro \%0 + name
  754.     mov    di,offset rdbuf+6    ; where to store text
  755.     mov    si,bx
  756.     add    si,2            ; source of text
  757.     cld
  758.     rep    movsb            ; copy name to rdbuf+6
  759.     mov    byte ptr [di],0        ; null terminator
  760.     pop    es
  761.     pop    cx
  762.     jmp    short getnam3        ; exit
  763. getnam2:mov    ax,[bx]            ; get length of name
  764.     add    ax,4            ; plus count and word pointer
  765.     add    bx,ax            ; point to next entry
  766.     pop    cx
  767.     loop    getnam1            ; look at next entry
  768. getnam3:pop    di
  769.     pop    si
  770.     pop    dx
  771.     pop    cx
  772.     pop    bx
  773.     ret
  774. getname    endp
  775.  
  776. ; Renames macros \%0..\%9 by changing the first two characters of the name
  777. ; to be <null><taklev>. Used to preserve old \%n macros and not show them.
  778. hidemac proc    near
  779.     push    bx
  780.     push    cx
  781.     mov    bx,offset mcctab+1    ; table of macro names, skip count
  782.     mov    cl,mcctab        ; number of entries
  783.     xor    ch,ch
  784.     jcxz    hidema3            ; z = empty table
  785. hidema1:cmp    word ptr [bx],3        ; name length, do three byte names
  786.     jne    hidema2            ; ne = not three chars
  787.     cmp    word ptr [bx+2],'%\'    ; starts with correct prefix?
  788.     jne    hidema2            ; ne = no
  789.     mov    al,byte ptr [bx+4]    ; third char of name
  790.     cmp    al,'0'            ; in digits?
  791.     jb    hidema2            ; b = no
  792.     cmp    al,'9'
  793.     ja    hidema2
  794.     xor    al,al            ; prepare new prefix
  795.     mov    ah,taklev        ; of <null><taklev>
  796.     mov    [bx+2],ax        ; change the macro name
  797. hidema2:mov    ax,[bx]            ; get length of name
  798.     add    ax,4            ; plus count and word pointer
  799.     add    bx,ax            ; point to next entry
  800.     loop    hidema1            ; look at next entry
  801. hidema3:pop    cx
  802.     pop    bx
  803.     ret
  804. hidemac    endp
  805.  
  806. ; Removes all current \%0..\%9 macros and renames <null><taklev> macros by
  807. ; changing the first two characters of the names \%n from <null><taklev> to
  808. ; be "\%". Used to recover old \%n macros from hidemac.
  809. unhidemac proc    near
  810.     push    cx
  811.     push    dx
  812.     push    di
  813.     mov    di,offset temptc    ; temp macro name
  814.     mov    word ptr [di+2],'%\'    ; prefix for "\%n"
  815.     mov    cl,'0'            ; trailer for name
  816.     xor    ch,ch            ; null terminator
  817. unhide1:mov    [di+4],cx        ; compose number
  818.     call    remtab            ; remove "\%n" macro
  819.     inc    cl
  820.     cmp    cl,'9'            ; done?
  821.     jna    unhide1            ; na = no, look at next entry
  822.                            ; now do rename of <null><taklev>n
  823. unhide2:mov    di,offset mcctab+1    ; table of macro names, skip count
  824.     mov    cl,mcctab        ; number of entries
  825.     xor    ch,ch
  826.     jcxz    unhide5            ; z = empty table
  827.     xor    dl,dl            ; macro prefix to examine
  828.     mov    dh,taklev
  829. unhide3:cmp    word ptr [di],3        ; do only "<null><taklev>n" names
  830.     jne    unhide4            ; ne = not three chars
  831.     mov    al,[di+4]        ; get char of name
  832.     cmp    al,'0'            ; is it a char in range for \%0..\%9?
  833.     jb    unhide4            ; b = no
  834.     cmp    al,'9'            ; still in range?
  835.     ja    unhide4            ; a = no
  836.     cmp    word ptr [di+2],dx    ; starts with <null><taklev> prefix?
  837.     jne    unhide4            ; ne = no
  838.     mov    [di+2],'%\'        ; change the macro name back to "\%n"
  839. unhide4:mov    ax,[di]            ; get length of name
  840.     add    ax,4            ; plus count and word pointer
  841.     add    di,ax            ; point to next entry
  842.     loop    unhide3            ; look at next entry
  843. unhide5:pop    di
  844.     pop    dx
  845.     pop    cx
  846.     ret
  847. unhidemac endp
  848.  
  849. ; DEFINE and ASSIGN macro commands
  850. ; Data structures comments. Macro name is stored in table mcctab as if we
  851. ; had used macro mkeyw, such as       mkeyw 'mymac',offset my_definition.
  852. ; In detail:    dw    length of name
  853. ;        db    'name'
  854. ;        dw    segment:0 of definition string
  855. ; Mcctab begins with a byte holding the number of macros in the table; one,
  856. ;  IBM, is established at assembly time. Mcctab is 10*macmax bytes long.
  857. ; Pointer mccptr holds the offset of the next free byte in mcctab.
  858. ; Definition strings are stored in individually allocated memory as
  859. ;        dw    length of definition string below
  860. ;        db    'definition string'
  861. ; A new definition is read into buffer rdbuf+2, where word rdbuf is reserved
  862. ;  to hold the length of the macro's name during intermediate processing.
  863. ; If the definition is absent then the macro is removed from the tables.
  864. ;
  865. ; ASSIGN is equivalent to DEFINE, except in the definition string substitution
  866. ; variable names are expanded to their definitions.
  867. ; DEFINE does not expand substitution variables.
  868. ; Both commands will remove a first level curly brace pair if, and only if,
  869. ; the definition begins and ends with them (trailing whitespace is allowed).
  870. ASSIGN    PROC    NEAR
  871.     mov    defkind,0        ; flag command as ASSIGN, vs DEFINE
  872.     jmp    short dodefcom        ; common code
  873. ASSIGN    ENDP
  874.  
  875. DODEF    PROC    NEAR
  876.     mov    defkind,1        ; flag command as DEFINE, vs ASSIGN
  877. DODEFCOM:
  878.     mov    comand.cmper,1        ; do not react to '\%' in macro name
  879.     mov    ah,cmword
  880.     mov    dx,offset rdbuf+2    ; buffer for macro name
  881.     mov    word ptr rdbuf,0
  882.     mov    comand.cmblen,length rdbuf ; length of analysis buffer
  883.     mov    bx,offset macmsg
  884.     call    comnd            ; get macro name
  885.     jnc    dodef1            ; nc = success
  886.     ret                ; failure
  887. dodef1:    or    ax,ax            ; null entry?
  888.     jnz    dodef2            ; nz = no
  889.     mov    dx,offset ermes6    ; more parameters needed
  890.     jmp    reterr
  891.  
  892. dodef2:    mov    bx,offset rdbuf+2    ; start of string
  893.     cmp    word ptr [bx],'%\'    ; \%<char> substitution variable?
  894.     jne    dodef2b            ; ne = no
  895.     cmp    ax,2            ; count, but missing <char>?
  896.     ja    dodef2a            ; a = no
  897.     mov    byte ptr [bx+2],'_'    ; slip in an underscore
  898. dodef2a:mov    ax,3            ; limit to \%<char>, one char name
  899.  
  900. dodef2b:add    bx,ax            ; point to string terminator
  901.     mov    byte ptr [bx],' '    ; replace null with space separator
  902.     mov    word ptr [bx+1],0    ; terminator, in case no command
  903.     inc    bx            ; where definition will start
  904.     mov    ax,cmdblen        ; length of rdbuf
  905.     sub    ax,bx            ; - (current offset - offset rdbuf)
  906.     add    ax,offset rdbuf        ; ax = amount of buffer used
  907.     mov    comand.cmblen,ax    ; our new buffer length
  908.     mov    al,defkind        ; get ASSIGN/DEFINE flag
  909.     mov    comand.cmper,al        ; react (DEF) to '\%' in definition
  910.     mov    ah,cmline        ; get a line of text
  911.     mov    dx,offset macmsg    ; help, bx is buffer offset
  912.     push    bx            ; save starting offset
  913.     call    comnd            ; get macro definition text
  914.     pop    bx
  915.     jnc    dodef3            ; nc = success
  916.     ret                ; failure
  917. dodef3:    add    bx,ax            ; end of command line
  918.     mov    cx,bx
  919.     sub    cx,offset rdbuf+2    ; length of command line
  920. ;;    jmp    dodecom
  921. DODEF    ENDP
  922.  
  923. ; Make a macro table entry and allocate buffer space.
  924. ; Enter with rdbuf+2 et seq = <macro name><spaces><arg><spaces><arg> ...
  925. ; and CX = byte count of line, starting at rdbuf+2.
  926. ; Word rdbuf+0 computed here as length of keyword.
  927. ; Allocates memory based on analyzed size of command line, returns memory
  928. ; segment in macptr and in AX. Returns carry set if failure.
  929. DODECOM    PROC    NEAR
  930.     push    si            ; macro name in rdbuf+1 et seq
  931.     push    di            ; cmd line length in deftemp
  932.     push    es
  933.     push    ds            ; address data segment
  934.     pop    es
  935.     mov    deftemp,cx        ; cmd line len, cx = running counter
  936.     mov    rdbuf,0            ; number of chars in keyword so far
  937.                     ; uppercase the keyword, look for end
  938.     mov    si,offset rdbuf+2    ; point at macro name itself
  939.     xor    dx,dx            ; a counter
  940.     cld                ; strings go forward
  941. dode2:    lodsb                ; get a byte
  942.     cmp    al,'a'            ; map lower case to upper
  943.     jb    dode3
  944.     cmp    al,'z'
  945.     ja    dode3
  946.     sub    al,'a'-'A'
  947.     mov    [si-1],al        ; uppercase if necessary
  948. dode3:    inc    dx            ; increment char count of keyword
  949.     cmp    al,' '            ; is this the break character?
  950.     loopne    dode2            ; no, loop thru rest of word
  951.     jne    dode4            ; ne = did not end with break char
  952.     dec    dx            ; yes, don't count in length
  953. dode4:    mov    di,offset rdbuf        ; point at mac name length
  954.     mov    [di],dx            ; insert length in rdbuf
  955.     push    dx            ; save length around call
  956.     call    remtab            ; remove any duplicate keyword
  957.                     ; check for free space for keyword
  958.     pop    ax            ; keyword text length
  959.     add    ax,4            ; plus count and word pointer
  960.     add    ax,mccptr        ; add to free space pointer
  961.     cmp    ax,offset mcctab+mcclen ; enough room for name?
  962.     jb    dode5            ; b = yes
  963.     mov    dx,offset ermes1    ; too many macro names
  964.     pop    es
  965.     pop    di
  966.     pop    si
  967.     jmp    reterr
  968.  
  969. dode5:    mov    dx,si            ; trim off leading/trailing spaces
  970.     call    strlen
  971.     mov    di,si            ; si = definition source address
  972.     jcxz    dode5a            ; z = empty string
  973.     add    di,cx            ; start + length
  974.     dec    di            ; last char of string
  975.     std
  976.     mov    al,' '            ; scan off trailing spaces
  977.     repe    scasb
  978.     cld
  979.     mov    byte ptr [di+2],0    ; plant new terminator
  980. dode5a:    mov    dx,si
  981.     call    strlen            ; get new length into cx
  982.     cld
  983.     mov    di,si            ; scan after keyword name
  984.     mov    al,' '            ; remove leading spaces in string
  985.     repe    scasb
  986.     jne    dode6            ; ne = have some text
  987.     pop    es            ; all spaces
  988.     pop    di
  989.     pop    si
  990.     clc                ; success
  991.     ret
  992. dode6:    dec    di            ; offset auto increment of rep
  993.     mov    si,di            ; new start of string
  994.     mov    dx,si            ; source of definition text
  995.     call    strlen            ; get length of string into cx
  996.     mov    deftemp,cx        ; remember it here
  997.                     ; install new keyword
  998.     jcxz    dode10            ; z = no def, exit now
  999.     mov    bx,cx            ; string length, in bytes
  1000.     add    bx,2+1+15        ; count + null term + round up
  1001.     mov    cl,4
  1002.     shr    bx,cl            ; convert to paragraphs (divide by 16)
  1003.     mov    cx,bx            ; remember desired paragraphs
  1004.     mov    ah,alloc        ; allocate a memory block
  1005.     int    dos
  1006.     jc    dode12            ; c = error, not enough memory
  1007.      cmp    bx,cx            ; obtained vs wanted
  1008.     jae    dode7            ; ae = enough
  1009.     mov    es,ax            ; allocated segment
  1010.     mov    ah,freemem        ; free it again
  1011.     int    dos
  1012.     jmp    short dode12        ; quit here
  1013.  
  1014. dode7:    mov    macptr,ax        ; store new segment
  1015.     mov    es,ax            ; segment of string
  1016.     xor    di,di            ; offset of count word
  1017.     mov    cx,deftemp        ; length of definition string
  1018.     mov    ax,cx
  1019.     cld
  1020.     stosw                ; store length of string
  1021.     rep    movsb            ; copy string
  1022.     mov    bx,offset mcctab    
  1023.     mov    dx,offset rdbuf        ; count word + name string
  1024.     call    addtab
  1025. dode10:    mov    ax,macptr        ; return buffer segment to caller
  1026.     pop    es
  1027.     pop    di
  1028.     pop    si
  1029.     clc                ; success
  1030.     ret
  1031. dode12:    pop    es            ; no memory, clean stack
  1032.     pop    di
  1033.     pop    si
  1034.     mov    dx,offset ermes2    ; no room for definition
  1035.     mov    ah,prstr
  1036.     int    dos
  1037.     stc
  1038.     ret
  1039. DODECOM    ENDP
  1040.  
  1041. ; ASK <variable or macro name> <prompt string>
  1042. ; Defines indicated variable/macro with text from user at keyboard or pipe
  1043. ; (but not from a Take/macro). Prompt string is required.
  1044. ; ASKQ does the same, but does not echo user's response.
  1045. ASKQ    PROC    NEAR
  1046.     mov    askecho,1        ; temp to flag as Quiet version
  1047.     jmp    short ask0        ; do common code
  1048. ASKQ    ENDP
  1049.  
  1050. ASK    PROC    NEAR
  1051.     mov    askecho,0        ; temp to flag as echoing version
  1052. ask0:                    ; common code for ASK and ASKQ
  1053.     mov    dx,offset rdbuf+2    ; point to work buffer
  1054.     mov    word ptr rdbuf,0
  1055.     mov    bx,offset askhlp1    ; help
  1056.     mov    comand.cmper,1        ; do not expand variable name
  1057.     mov    ah,cmword        ; get variable name
  1058.     call    comnd
  1059.     jnc    ask1            ; nc = success
  1060.     ret                ; failure
  1061. ask1:    or    ax,ax            ; anything given?
  1062.     jnz    ask2            ; nz = yes
  1063.     mov    dx,offset ermes6    ; more parameters needed
  1064.     jmp    reterr
  1065.  
  1066. ask2:    cmp    word ptr rdbuf+2,'%\'    ; \%<char> substitution variable?
  1067.     jne    ask2b            ; ne = no
  1068.     cmp    al,2            ; but missing <char>
  1069.     ja    ask2a            ; a = no
  1070.     mov    rdbuf+4,'_'        ; slip in an underscore
  1071. ask2a:    mov    ax,3            ; limit to a single char
  1072. ask2b:    mov    bx,offset rdbuf+2    ; start of name
  1073.     add    bx,ax            ; plus length of variable name
  1074.     mov    byte ptr [bx],' '    ; put space separator after name
  1075.     inc    ax            ; count space
  1076.     mov    numhlp,ax        ; remember length here
  1077.                     ; get ASK command prompt string
  1078.     mov    bx,offset decbuf    ; borrowed buffer for prompt
  1079.     mov    byte ptr [bx],0        ; safety terminator
  1080.     mov    dx,offset askhlp2
  1081.     mov    comand.cmblen,127    ; our buffer length
  1082.     sub    comand.cmblen,ax    ;  minus part used above
  1083.     mov    ah,cmline        ; get prompt string
  1084.     call    comnd
  1085.     jnc    ask3            ; nc = success
  1086.     ret                ; failure
  1087. ask3:    or    ax,ax            ; anything given?
  1088.     jnz    ask4            ; nz = yes
  1089.     mov    dx,offset ermes6    ; more parameters needed
  1090.     jmp    reterr
  1091.  
  1092. ask4:    mov    ax,takadr        ; we could be in a macro or Take file
  1093.     mov    temp2,ax        ; save Take address
  1094.     mov    al,taklev
  1095.     xor    ah,ah
  1096.     mov    temp1,ax        ; and Take level
  1097.     mov    dx,size takinfo        ; bytes for each current Take
  1098.     mul    dx            ; times number of active Take/macros
  1099.     sub    takadr,ax        ; clear Take address as if no
  1100.     mov    taklev,0        ;  Take/macro were active so that
  1101.                     ;  user input is from kbd or pipe
  1102.     mov    word ptr [bx],0020h    ; printing terminator for prompt
  1103.     mov    si,offset decbuf
  1104.     mov    di,si            ; convert in-place
  1105.     call    cnvlin            ; convert backslash items
  1106.     mov    dx,si            ; converted prompt string, asciiz
  1107.      call    prompt            ; use our prompt
  1108.     mov    bx,offset rdbuf+129    ; use this buffer for raw user input
  1109.     mov    word ptr [bx],0        ; insert terminator
  1110.     mov    dl,askecho        ; get echo/quiet flag
  1111.     mov    comand.cmquiet,dl    ; 0 if echoing
  1112.     mov    dx,offset askhlp3    ; help for user input
  1113.     mov    ah,cmline        ; read user's input string
  1114.     call    comnd
  1115.     mov    comand.cmquiet,0    ; permit echoing again
  1116.     mov    cx,temp2
  1117.     mov    takadr,cx        ; restore Take address
  1118.     mov    cx,temp1
  1119.     mov    taklev,cl        ; restore Take level
  1120.     jnc    ask5            ; nc = success
  1121.     ret                ; Control-C, quit now
  1122. ask5:    mov    cx,ax            ; length of entry
  1123.     mov    si,offset rdbuf+129    ; source string
  1124.     mov    di,offset rdbuf+2    ; start of variable name
  1125.     add    di,numhlp        ; di points to final user string
  1126.     push    es            ; save es
  1127.     push    ds
  1128.     pop    es            ; set es to data segment
  1129.     cld
  1130.     jcxz    ask8            ; z = empty
  1131.     rep    movsb            ; copy string
  1132. ask8:    xor    al,al            ; get null terminator
  1133.     stosb                ; plant it
  1134.     pop    es
  1135.      mov    dx,offset rdbuf+2    ; command buffer beginning
  1136.     call    strlen            ; CX=len of <variable>< ><user string>
  1137.     jmp    DODECOM            ; define the macro/variable and exit
  1138. ASK    ENDP
  1139.  
  1140. ; Initialize macro IBM at Kermit startup time
  1141. initibm    proc    near
  1142.     mov    si,offset ibmmac    ; text of IBM macro
  1143.     mov    di,offset rdbuf+2    ; where command lines go
  1144.     call    strcpy            ; copy it there
  1145.     mov    dx,di            ; get length of command line
  1146.     call    strlen            ; set cx to length, for dodecom
  1147.     jmp    dodecom            ; now define the macro
  1148. initibm    endp
  1149.  
  1150. ; Open a disk based Take file buffer. Define macro named "<null>T<'taklev'>",
  1151. ; in mcctab and allocate 128 byte uninitiated buffer for disk i/o. Leading null
  1152. ; is to prevent user from employing the same name accidentally. Return seg
  1153. ; of buffer in [takadr].takbuf and set [takadr].takptr to offset of first
  1154. ; byte after leading count byte. Uses dodecom to make this macro.
  1155. ; Return carry clear for success, carry set for failure.
  1156.  
  1157. TAKOPEN    PROC    NEAR
  1158.     push    ax
  1159.     push    bx
  1160.     push    cx
  1161.     push    dx
  1162.     cmp    taklev,maxtak        ; room in take level?
  1163.     jb    takope1            ; b = yes
  1164.     mov    dx,offset ermes4    ; say too many Take files
  1165.     mov    ah,prstr        ; display error message
  1166.     int    dos
  1167.     stc                ; set carry for failure
  1168.     jmp    short takope2
  1169.  
  1170. takope1:mov    word ptr rdbuf,3    ; length of name, 3 bytes <null>Tn
  1171.     mov    rdbuf+2,0
  1172.     mov    rdbuf+3,'T'        ; name of <null>Tn
  1173.     mov    al,taklev        ; Take level digit
  1174.     inc    al            ; for what will be next Take level
  1175.     add    al,'0'            ; add ascii bias
  1176.     mov    rdbuf+4,al        ; last of the name
  1177.     mov    rdbuf+5,' '        ; separate dummy definition
  1178.     mov    cx,tbufsiz        ; fill with dummy non-blank data
  1179.     push    cx            ; length of buffer, for dodecom
  1180.     push    di
  1181.     push    es            ; save es
  1182.     push    ds            ; set es to data segment
  1183.     pop    es
  1184.     cld
  1185.     mov    al,'.'            ; dummy fill pattern
  1186.     mov    di,offset rdbuf+6    ; definition text starts here
  1187.     rep    stosb            ; store the pattern
  1188.     pop    es
  1189.     pop    di
  1190.     pop    cx            ; get command length again
  1191.     call    dodecom            ; define our Take macro
  1192.     jc    takope2            ; c = failure
  1193.     xor    ax,ax
  1194.     xor    cx,cx
  1195.     cmp    taklev,0        ; at top level now?
  1196.     je    takope3            ; e = yes
  1197.     mov    bx,takadr
  1198.     mov    ax,[bx].takargc        ; get argument count
  1199.     mov    cx,[bx].takctr        ; get COUNT
  1200. takope3:add    takadr,size takinfo    ; pointer to new Take structure
  1201.     inc    taklev
  1202.     mov    bx,takadr        ; pointer to new Take structure
  1203.     mov    [bx].takargc,ax        ; copy in old argc
  1204.     mov    [bx].takctr,cx        ; copy in old count
  1205.     mov    ax,macptr        ; segment of buffer
  1206.     mov    [bx].takbuf,ax        ; segment of Take buffer
  1207.     mov    [bx].takcnt,tbufsiz-2    ; number of unread bytes
  1208.     mov    [bx].takptr,2        ; init pointer to definition itself
  1209.     clc                ; carry clear for success
  1210. takope2:pop    dx
  1211.     pop    cx
  1212.     pop    bx
  1213.     pop    ax
  1214.     ret
  1215. TAKOPEN    ENDP
  1216.  
  1217. ; Close Take file. Enter at Take level to be closed. Removes pseudo macro
  1218. ; name <null>Tn and its buffer, closes disk file, pops Take level.
  1219.  
  1220. TAKCLOS    PROC    NEAR
  1221.     cmp    taklev,0        ; anything to close?
  1222.     jle    takclo3            ; le = no
  1223.     push    ax
  1224.     push    bx
  1225.     push    cx
  1226.     mov    al,taklev        ; Take level digit
  1227.     add    al,'0'            ; add ascii bias
  1228.     mov    temptc+2,0
  1229.     mov    temptc+3,'T'
  1230.     mov    temptc+4,al        ; last of the name
  1231.     push    di
  1232.     mov    di,offset temptc    ; pointer for remtab
  1233.     call    remtab            ; remove possible old macro and buffer
  1234.     pop    di
  1235.     mov    bx,takadr        ; point to Take structure
  1236.     mov    al,[bx].taktyp
  1237.     cmp    [bx].taktyp,0feh    ; disk file?
  1238.     jne    takclo1            ; ne = no, no buffer to deallocate
  1239.     mov    bx,[bx].takhnd        ; get file handle
  1240.     mov    ah,close2        ; close file
  1241.     int    dos
  1242.     dec    taklev            ; pop disk file Take level
  1243.     sub    takadr,size takinfo    ; get previous Take's address
  1244.     jmp    short takclo2
  1245.  
  1246. takclo1:dec    taklev            ; pop macro Take level
  1247.     sub    takadr,size takinfo    ; get previous Take's address
  1248.     cmp    al,0ffh            ; regular macro?
  1249.     jne    takclo2            ; ne = no, no unhiding necessary
  1250.     call    unhidemac        ; rename previous \%n macros
  1251. takclo2:pop    cx
  1252.     pop    bx
  1253.     pop    ax            ; close prev Take/Macro if at EOF too
  1254.      cmp    taklev,0        ; Take/macro still open?
  1255.     je    takclo3            ; e = no
  1256.     push    bx
  1257.     mov    bx,takadr        ; get it's address
  1258.     cmp    [bx].takcnt,0        ; is it at EOF?
  1259.     pop    bx
  1260.     ja    takclo3            ; a = no
  1261.     jmp    takclos            ; yes, close it too
  1262. takclo3:ret
  1263. TAKCLOS    ENDP
  1264.  
  1265. ; POP/END command. Defend against command parser closing the Take/Macro at
  1266. ; the end of file. Return optional trailing number in ERRORLEVEL (errlev).
  1267. POPCMD    proc    near
  1268.     mov    ah,cmword        ; get optional error value
  1269.     mov    dx,offset rdbuf+1
  1270.     mov    rdbuf,'\'        ; in case the user did not specify
  1271.     mov    bx,offset pophlp    ; help on numerical argument
  1272.     mov    comand.cmcr,1        ; bare c/r's allowed
  1273.     call    comnd
  1274.     mov    comand.cmcr,0        ; restore normal state
  1275.     jc    popcmd3            ; c = failure
  1276.     mov    ah,cmeol        ; confirm
  1277.     call    comnd
  1278.     jc    popcmd3
  1279.     mov    si,offset rdbuf
  1280.     cmp    byte ptr [si+1],'\'    ; user specified?
  1281.     jne    popcmd1            ; ne = no, use ours
  1282.     inc    si            ; yes, use theirs
  1283. popcmd1:call    katoi            ; convert to number in ax
  1284.     jc    popcmd2            ; c = not a number
  1285.     mov    errlev,al        ; return value in ERRORLEVEL
  1286.     mov    kstatus,ax        ; and in STATUS
  1287. popcmd2:mov    al,oldtak        ; Take level previous to this cmd
  1288.     sub    al,taklev        ; minus Take level now
  1289.     ja    popcmd3            ; a = have exited macro already
  1290.     jmp    takclos            ; close current Macro/Take
  1291. popcmd3:ret
  1292. POPCMD    endp
  1293.  
  1294. ; add an entry to a keyword table
  1295. ; enter with bx = table address, dx = ptr to new entry, macptr = string seg
  1296. ; mccptr = offset of free bytes in table mcctab.
  1297. ; no check is made to see if the entry fits in the table.
  1298. addtab    proc    near
  1299.     push    cx
  1300.     push    si
  1301.     push    es
  1302.     push    bp
  1303.     cld
  1304.     mov    ax,ds
  1305.     mov    es,ax        ; address data segment
  1306.     mov    bp,bx        ; remember where macro name table starts
  1307.     mov    cl,[bx]        ; pick up length of table
  1308.     xor    ch,ch
  1309.     inc    bx        ; point to actual table
  1310.     jcxz    addta4        ; cx = 0 if table is presently empty
  1311.  
  1312. addta1:    push    cx        ; preserve count
  1313.     mov    si,dx        ; point to entry
  1314.     lodsw            ; get length of new entry
  1315.     mov    cx,[bx]        ; and length of table entry
  1316.     cmp    ax,cx        ; are they the same?
  1317.     lahf            ; remember result of comparison
  1318.     jae    addta2        ; is new smaller? ae = no, use table length
  1319.     mov    cx,ax        ; else use length of new entry
  1320. addta2:    lea    di,[bx+2]    ; point to actual keyword
  1321.     repe    cmpsb        ; compare strings
  1322.     pop    cx        ; restore count
  1323.     jb    addta4        ; below, insert before this one
  1324.     jne    addta3        ; not below or same, keep going
  1325.     sahf            ; same. get back result of length comparison
  1326.     jb    addta4        ; if new len is smaller, insert here
  1327.     jne    addta3        ; if not same size, keep going
  1328.     mov    si,bx        ; else this is where entry goes
  1329.     jmp    short addta6    ; no insertion required
  1330. addta3:    mov    ax,[bx]        ; length of keyword
  1331.     add    bx,ax        ; skip this entry
  1332.     add    bx,4        ; length word and 16 bit value
  1333.     loop    addta1        ; and keep looking
  1334. addta4:    mov    si,bx        ; this is first location to move
  1335.     mov    di,bx
  1336.     inc    ds:byte ptr [bp] ; remember we're adding one
  1337.     jcxz    addta6        ; z = no more entries, forget this stuff
  1338. addta5:    mov    bx,[di]        ; get length
  1339.     lea    di,[bx+di+4]    ; end is origin + length + 4 for len, value
  1340.     loop    addta5        ; loop thru remaining keywords
  1341.     mov    cx,di
  1342.     sub    cx,si        ; compute # of bytes to move
  1343.     push    si        ; preserve loc for new entry
  1344.     mov    si,di        ; first to move is last
  1345.     dec    si        ; minus one
  1346.     mov    di,dx        ; new entry
  1347.     mov    bx,[di]        ; get length
  1348.     lea    di,[bx+si+4]    ; dest is source + length of new + 4
  1349.     std            ; move backward
  1350.     rep    movsb        ; move the table down (compress it)
  1351.     cld            ; put flag back
  1352.     pop    si
  1353. addta6:    mov    di,si        ; this is where new entry goes
  1354.     mov    si,dx        ; this is where it comes from
  1355.     mov    cx,[si]        ; length of name
  1356.     add    cx,2        ; include count byte
  1357.     add    mccptr,cx    ; update free space pointer: cnt+name
  1358.     rep    movsb        ; insert new entry
  1359.     mov    ax,macptr    ; and string address
  1360.     stosw
  1361.     add    mccptr,2    ; plus string address
  1362.     pop    bp
  1363.     pop    es
  1364.     pop    si
  1365.     pop    cx
  1366.     ret
  1367. addtab    endp
  1368.  
  1369. ; If new keyword matches an existing one then remove existing keyword,
  1370. ; its string definition, compress tables mcctab and macbuf, readjust string
  1371. ; pointers for each macro name, reduce number of macro table entries by one.
  1372. ; Enter with DI pointing at length word of mac name (followed by mac name).
  1373. ; Otherwise, exit with no changes.  13 June 1987 [jrd]
  1374. remtab    proc    near
  1375.     push    ax
  1376.     push    bx
  1377.     push    cx
  1378.     push    si
  1379.     push    di
  1380.     mov    bx,temp            ; preserve
  1381.     push    bx
  1382.     mov    bx,offset mcctab+1    ; table of macro keywords
  1383.     mov    temp,0            ; temp = current keyword
  1384.     cmp    byte ptr mcctab,0    ; any macros defined?
  1385.     jne    remta1            ; ne = yes
  1386.     jmp    remtax            ; else exit now
  1387. remta1:                    ; match table keyword and text word
  1388.     mov    si,di            ; pointer to user's cnt+name
  1389.     mov    cx,[si]            ; length of user's macro name
  1390.     add    si,2            ; point to new macro name
  1391.     cmp    cx,[bx]            ; compare length vs table keyword
  1392.     jne    remta4            ; ne = not equal lengths, try another
  1393.     push    si            ; lengths match, how about spelling?
  1394.     push    bx
  1395.     add    bx,2            ; point at start of keyword
  1396. remta2:    mov    ah,[bx]            ; keyword char
  1397.     mov    al,[si]            ; new text char
  1398.     cmp    al,ah            ; test characters
  1399.     jne    remta3            ; ne = no match
  1400.     inc     si            ; move to next char
  1401.     inc    bx
  1402.     loop    remta2            ; loop through entire length
  1403. remta3:    pop    bx
  1404.     pop    si
  1405.     jcxz    remta6            ; z: cx = 0, exit with match;
  1406.                     ;  else select next keyword
  1407. remta4:    inc    temp            ; number of keyword to test next
  1408.     mov    cx,temp
  1409.     cmp    cl,mcctab        ; all done? Recall, temp starts at 0
  1410.     jb    remta5            ; b = not yet
  1411.     jmp    remtax            ; exhausted search, unsuccessfully
  1412. remta5:    mov    ax,[bx]            ; cnt (keyword length from macro)
  1413.     add    ax,4            ; skip count and word pointer
  1414.     add    bx,ax            ; bx = start of next keyword slot
  1415.     jmp    short remta1        ; do another comparison
  1416.                     ; new name already present as a macro
  1417. remta6:    cld                ; clear macro string and macro name
  1418.     push    ds
  1419.     pop    es            ; set es to data segment
  1420.     mov    temp,bx            ; save ptr to found keyword
  1421.     mov    ax,[bx]            ; cnt (keyword length of macro)
  1422.     add    ax,2            ; skip cnt
  1423.     add    bx,ax            ; point to string segment field
  1424.     add    ax,2            ; count segment field bytes
  1425.     sub    mccptr,ax        ; readjust free space ptr for names
  1426.     push    bx
  1427.     push    es
  1428.     mov    es,[bx]            ; segment of string
  1429.     mov    ax,ds            ; check for being in our data segment
  1430.     cmp    ax,[bx]            ; same as our data seg?
  1431.     je    remta7            ; e = yes, don't free that
  1432.     mov    ah,freemem        ; free that memory block
  1433.     int    dos
  1434. remta7:    pop    es
  1435.     pop    bx
  1436.                     ; clear keyword table mcctab
  1437.     add    bx,2            ; compute source = next keyword
  1438.     mov    si,bx            ; address of next keyword
  1439.     mov    di,temp            ; address of found keyword
  1440.     mov    cx,offset mcctab+mcclen ; address of buffer end
  1441.     sub    cx,si            ; amount to move
  1442.     jcxz    remtax            ; cx = 0 means none
  1443.     rep    movsb            ; move down keywords (deletes current)
  1444.     dec    mcctab            ; one less keyword
  1445. remtax:    pop    temp            ; recover temp variable
  1446.     pop    di
  1447.     pop    si
  1448.     pop    cx
  1449.     pop    bx
  1450.     pop    ax
  1451.     ret
  1452. remtab    endp
  1453.  
  1454. ; Common Get keyword + Get Confirm sequence. Call with dx = keyword table,
  1455. ; bx = help message offset. Returns result in BX. Modifies AX, BX.
  1456. ; Returns carry clear if sucessful else carry set. Used in many places below.
  1457. keyend    proc    near
  1458.     mov    ah,cmkey
  1459.     call    comnd
  1460.     jnc    keyend1            ; nc = success
  1461.     ret                ; failure
  1462. keyend1:push    bx            ; save returned results around call
  1463.     mov    ah,cmeol        ; get c/r confirmation
  1464.     call    comnd
  1465.     pop    bx            ; recover keyword 16 bit value
  1466.     ret                ; return with carry from comnd
  1467. keyend    endp
  1468.  
  1469. srvdsa    proc    near            ; DISABLE Server commands
  1470.     mov    dx,offset srvdetab
  1471.     mov    bx,offset sdshlp
  1472.     call    keyend
  1473.     jc    srvdsa1            ; c = failure
  1474.     or    denyflg,bx        ; turn on bit (deny) for that item
  1475. srvdsa1:ret
  1476. srvdsa    endp
  1477.  
  1478. srvena    proc    near            ; ENABLE Server commands
  1479.     mov    dx,offset srvdetab    ; keyword table
  1480.     mov    bx,offset sdshlp    ; help on keywords
  1481.     call    keyend
  1482.     jc    srvena1            ; c = failure
  1483.     not    bx            ; invert bits
  1484.     and    denyflg,bx        ; turn off (enable) selected item
  1485. srvena1:ret
  1486. srvena    endp
  1487.  
  1488.  
  1489. ; This is the SET command
  1490. ; Called analyzers return carry clear for success, else carry set.
  1491. SETCOM    PROC    NEAR            ; Dispatch all SET commands from here
  1492.     mov    kstatus,kssuc        ; global status, success
  1493.     mov    dx,offset settab    ; Parse a keyword from the set table
  1494.     mov    bx,offset sethlp
  1495.     mov    ah,cmkey
  1496.     call    comnd
  1497.     jc    setcom1            ; c = failure
  1498.     jmp    bx            ; execute analyzer routine
  1499. setcom1:ret
  1500. SETCOM    endp
  1501.  
  1502. SETATT    PROC    NEAR            ; Set attributes on | off
  1503.     mov    dx,offset atttab
  1504.     xor    bx,bx
  1505.     mov    ah,cmkey
  1506.     call    comnd
  1507.     jc    setatt3            ; c = failure
  1508.     mov    dx,bx            ; hold results in dx
  1509.     cmp    dl,0ffh            ; ON/OFF (all of them)?
  1510.     je    setatt1            ; e = yes
  1511.     push    dx
  1512.     mov    dx,offset ontab        ; get on/off state
  1513.     xor    bx,bx
  1514.     mov    ah,cmkey
  1515.     call    comnd
  1516.     pop    dx
  1517.     jc    setatt3            ; c = failure
  1518.     mov    dh,bl            ; store on/off state in dh
  1519. setatt1:push    dx
  1520.     mov    ah,cmeol
  1521.     call    comnd
  1522.     pop    dx
  1523.     jc    setatt3
  1524.     mov    al,flags.attflg        ; current flags
  1525.     not    dl            ; all but those affected
  1526.     and    al,dl            ; turn off affected flags
  1527.     or    dh,dh            ; off (dh = 0)?
  1528.     jz    setatt2            ; z = yes
  1529.     not    dl            ; affected flags back again as ones
  1530.     or    al,dl            ; turn on affected flags
  1531. setatt2:mov    flags.attflg,al
  1532. setatt3:ret
  1533. SETATT    ENDP
  1534.  
  1535. ; SET BAUD or SET SPEED
  1536. ; See system dependent routine BAUDST in file MSXxxx.ASM
  1537.  
  1538. ; SET BELL on or off
  1539.  
  1540. BELLST    PROC    NEAR
  1541.     mov    dx,offset ontab        ; on/off table
  1542.     xor    bx,bx            ; help
  1543.     call    keyend
  1544.     jc    bellst1            ; c = failure
  1545.     mov    flags.belflg,bl
  1546. bellst1:ret
  1547. BELLST    ENDP
  1548.  
  1549. ; SET BLOCK-CHECK
  1550.  
  1551. BLKSET    PROC    NEAR
  1552.     mov    dx,offset blktab    ; table
  1553.     xor    bx,bx            ; help, use table
  1554.     call    keyend
  1555.     jc    blkset1            ; c = failure
  1556.     mov    dtrans.chklen,bl    ; use this char as initial checksum
  1557. blkset1:ret
  1558. BLKSET    ENDP
  1559.  
  1560.  
  1561. ; Set port addresses for COM1 .. COM4 at Kermit initialization time via
  1562. ; Environment. Called by command parser while doing Environment reading in
  1563. ; mssker.asm and via SET COM1 .. SET COM4.
  1564. COM1PORT proc    near
  1565.     mov    bx,0            ; offset of com1 port address
  1566.     jmp    short comport
  1567. COM1PORT endp
  1568. COM2PORT proc    near
  1569.     mov    bx,2            ; offset of com2 port address
  1570.     jmp    short comport
  1571. COM2PORT endp
  1572. COM3PORT proc    near
  1573.     mov    bx,4            ; offset of com3 port address
  1574.     jmp    short comport
  1575. COM3PORT endp
  1576.  
  1577. COM4PORT proc    near
  1578.     mov    bx,6            ; offset of com4 port address
  1579. ;;    jmp    comport
  1580. COM4PORT endp
  1581.  
  1582. COMPORT    proc    near            ; worker for above
  1583.     push    bx            ; save offset
  1584.     mov    dx,offset rdbuf+1
  1585.     mov    word ptr rdbuf,0
  1586.     mov    bx,offset comhlp
  1587.     mov    ah,cmword        ; get port address number
  1588.     call    comnd
  1589.     jnc    compor3
  1590.     pop    bx            ; fail
  1591.     ret
  1592. compor3:mov    numerr,0        ; no error message
  1593.     mov    min,100h        ; smallest number
  1594.     mov    max,0fff0h        ; largest magnitude
  1595.     mov    numhlp,0        ; help
  1596.     call    numwd            ; parse this word
  1597.     jnc    compor4            ; nc = success, value in ax
  1598.     pop    bx
  1599.     ret
  1600. compor4:mov    temp1,ax        ; save port address
  1601.     mov    dx,offset rdbuf+1
  1602.     mov    word ptr rdbuf,0
  1603.     mov    bx,offset irqhlp
  1604.     mov    temp2,0
  1605.     mov    ah,cmword        ; read IRQ
  1606.     call    comnd
  1607.     jnc    compor5
  1608.     pop    bx
  1609.     ret
  1610. compor5:push    ax
  1611.     mov    ah,cmeol        ; get command confirmation
  1612.     call    comnd
  1613.     pop    ax
  1614.     jnc    compor5a        ; nc = success
  1615.     ret
  1616. compor5a:or    ax,ax            ; anything given?
  1617.     jz    compor7            ; z = no
  1618.     mov    numhlp,0        ; help
  1619.     mov    numerr,0        ; no error message
  1620.     mov    min,2            ; smallest number
  1621.     mov    max,15            ; largest magnitude
  1622.     call    numwd            ; parse this word
  1623.     jnc    compor6            ; nc = success
  1624.     pop    bx
  1625.     ret
  1626. compor6:mov    temp2,ax        ; save IRQ
  1627. compor7:pop    bx            ; recover offset
  1628.     cmp    word ptr machnam,'BI'    ; check for "IBM-PC"
  1629.     jne    compor1            ; ne = not this name, fail
  1630.     cmp    word ptr machnam+2,'-M'
  1631.     jne    compor1
  1632.     cmp    word ptr machnam+4,'CP'
  1633.     jne    compor1
  1634.     push    es
  1635.     mov    al,flags.comflg        ; current comms port
  1636.     dec    al            ; count from 0, as per Bios
  1637.     shl    al,1            ; double to use word index of Bios
  1638.     cmp    al,bl            ; using this port now?
  1639.     jne    compor2            ; ne = no
  1640.     call    serrst            ; reset the port
  1641. compor2:mov    cx,40h            ; segment 40h
  1642.     mov    es,cx
  1643.     mov    ax,temp1        ; port address
  1644.     mov    es:[bx],ax        ; set port address
  1645.     pop    es
  1646.     shr    bl,1            ; coms port offset 0,2,4,6 to 0,1,2,3
  1647.     mov    ax,temp2        ; IRQ
  1648.     mov    portirq[bx],al
  1649.     clc
  1650. compor1:ret
  1651. COMPORT    endp
  1652.  
  1653. ; SET COUNTER number    for script IF COUNTER number <command>
  1654. TAKECTR    PROC    NEAR
  1655.     mov    min,0            ; get decimal char code
  1656.     mov    max,65535        ; range is 0 to 65535 decimal
  1657.     mov    numhlp,offset takchlp    ; help message
  1658.     mov    numerr,0        ; error message
  1659.     call    num0            ; convert number, return it in ax
  1660.     jc    takect2            ; c = error
  1661.     push    ax            ; save numerical code
  1662.     mov    ah,cmeol
  1663.     call    comnd            ; get a confirm
  1664.     pop    ax            ; recover ax
  1665.     jc    takect2            ; c = failure
  1666.     cmp    taklev,0        ; in a Take file?
  1667.     je    takect4            ; e = no
  1668.     push    bx
  1669.     mov    bx,takadr
  1670.     mov    [bx].takctr,ax        ; set COUNT value
  1671.     pop    bx
  1672.     clc                ; success
  1673. takect2:ret
  1674. takect4:mov    dx,offset takcerr    ; say must be in Take file
  1675.     jmp    reterr            ; display msg and return carry clear
  1676. TAKECTR    ENDP
  1677.  
  1678. ; SET DEBUG {OFF | ON | SESSSION | PACKETS}
  1679.  
  1680. DEBST    PROC       NEAR
  1681.     mov    dx,offset debtab
  1682.     mov    bx,offset debhlp
  1683.     call    keyend
  1684.     jnc    debst1            ; nc = success
  1685.     ret                ; failure
  1686. debst1:    or    flags.debug,bl        ; set the mode, except for Off
  1687.     or    bx,bx            ; OFF?
  1688.     jnz    debst2            ; nz = no
  1689.     mov    flags.debug,bl        ; set the DEBUG flags off
  1690. debst2:    clc                ; success
  1691.     ret
  1692. DEBST    ENDP
  1693.  
  1694. ; SET DESTINATION   of incoming files
  1695.  
  1696. DESSET    PROC    NEAR
  1697.     mov    dx,offset destab
  1698.     xor    bx,bx
  1699.     call    keyend
  1700.     jc    desset1            ; c = failure
  1701.     mov    flags.destflg,bl    ; set the destination flag
  1702. desset1:ret
  1703. DESSET    ENDP
  1704.  
  1705. ; SET DEFAULT-DISK    for sending/receiving, etc
  1706. ; See cwdir in file mssker
  1707.  
  1708. ; SET DELAY seconds   Used only for SEND command in local mode
  1709. SETDELY    PROC    NEAR
  1710.     mov    min,0            ; smallest acceptable value
  1711.     mov    max,63            ; largest acceptable value
  1712.     mov    numhlp,offset delyhlp    ; help message
  1713.     mov    numerr,0        ; complaint message
  1714.     call    num0            ; parse numerical input
  1715.     jc    setdly1            ; c = error
  1716.     mov    trans.sdelay,al
  1717. setdly1:ret                ; success or failure
  1718. SETDELY    ENDP
  1719.  
  1720. ; SET DISPLAY Quiet/Regular/Serial/7-Bit/8-Bit (inverse of Set Remote on/off)
  1721. ; Accepts two keywords in one command
  1722. disply    proc    near
  1723.     mov    ah,cmkey
  1724.     mov    dx,offset distab
  1725.     mov    bx,offset dishlp
  1726.     call    comnd
  1727.     jnc    displ0            ; nc = success
  1728.     ret                ; return failure
  1729. displ0:    mov    temp1,bx        ; save parsed value
  1730.     mov    temp2,0ffffh        ; assume no second keyword
  1731.     mov    comand.cmcr,1        ; bare CR's are allowed
  1732.     mov    ah,cmkey        ; parse for second keyword
  1733.     mov    dx,offset distab
  1734.     mov    bx,offset dishlp
  1735.     call    comnd
  1736.     jc    displ1            ; no keyword
  1737.     mov    temp2,bx        ; get key value
  1738. displ1:    mov    comand.cmcr,0        ; bare CR's are not allowed
  1739.     mov    ah,cmeol
  1740.     call    comnd            ; confirm
  1741.     jnc    displ2            ; nc = success
  1742.     ret                ; failure
  1743. displ2:    mov    ax,temp1        ; examine first key value
  1744.     call    dispcom            ; do common code
  1745.     mov    ax,temp2        ; examine second key value
  1746. ;    jmp    dispcom            ; finish in common code
  1747.  
  1748. dispcom:or    ax,ax            ; check range
  1749.     jle    dispc3            ; le = not legal, ignore
  1750.     cmp    al,7            ; 7-8 bit value?
  1751.     jge    dispc2            ; ge = yes
  1752.     and    flags.remflg,not(dquiet+dregular+dserial)
  1753.     or    flags.remflg,al        ; set display mode
  1754.     clc                ; success
  1755.     ret                ; check next key value
  1756. dispc2:    cmp    al,8            ; set 8-bit wide display?
  1757.     ja    dispc3            ; a = bad value
  1758.     and    flags.remflg,not d8bit    ; assume want 7 bit mode
  1759.     cmp    al,7            ; really want 7 bit mode?
  1760.     je    dispc3            ; e = yes
  1761.     or    flags.remflg,d8bit    ; set 8 bit flag
  1762. dispc3:    clc                ; success
  1763.     ret                ; end of display common code
  1764. disply    endp
  1765.  
  1766.  
  1767. ; Set Dump filename  for saving screen images on disk.
  1768. ; Puts filename in global string dmpname
  1769. setdmp    proc    near
  1770.     mov    dx,offset rdbuf        ; work area
  1771.     mov    rdbuf,0            ; clear it
  1772.     mov     bx,offset dmphlp    ; help message
  1773.     mov    ah,cmword        ; allow paths
  1774.     call    comnd
  1775.     jc    setdmp2            ; c = failure
  1776.     mov    ah,cmeol
  1777.     call    comnd
  1778.     jc    setdmp2            ; c = failure
  1779.     mov    dx,offset rdbuf        ; assume we will use this text
  1780.     call    strlen            ; filename given?
  1781.     mov    si,dx            ; for strcpy
  1782.     or    cx,cx            ; length of user's filename
  1783.     jg    setdmp1            ; g = filename is given
  1784.     mov    si,offset dmpdefnam    ; no name, use default instead
  1785. setdmp1:mov    di,offset dmpname    ; copy to globally available loc
  1786.     call    strcpy
  1787.     clc
  1788. setdmp2:ret
  1789. setdmp    endp
  1790.  
  1791. ; Set DUPLEX {FULL, HALF}
  1792. setdup    proc    near
  1793.     xor    bx,bx
  1794.     mov    dx,offset duptab
  1795.     call    keyend
  1796.     jc    setdup1            ; c = failure
  1797.     mov    si,portval
  1798.     mov    [si].duplex,bl        ; set value
  1799.     mov    [si].ecoflg,0        ; turn off local echoing
  1800.     or    bl,bl            ; full duplex?
  1801.     jz    setdup1            ; z = yes
  1802.     mov    [si].floflg,0        ; no flow control for half duplex
  1803.     mov    [si].ecoflg,1        ; turn on local echoing
  1804.     call    serrst            ; reset port so opening uses above
  1805. setdup1:ret
  1806. setdup    endp
  1807.  
  1808. ; SET EOF
  1809.  
  1810. SETEOF    PROC    NEAR
  1811.     xor    bx,bx
  1812.     mov    dx,offset seoftab
  1813.     call    keyend
  1814.     jc    seteof1            ; c = failure
  1815.     mov    flags.eofcz,bl        ; set value
  1816. seteof1:ret
  1817. SETEOF    ENDP
  1818.  
  1819. ; SET End-of-Packet char (for Sent packets)
  1820. ; Archic, here for downward compatibility
  1821. EOLSET    PROC    NEAR
  1822.     mov    stflg,'S'        ; set send/receive flag to Send
  1823.     jmp    sreol            ; use Set Send/Rec routine do the work
  1824. EOLSET    ENDP
  1825.  
  1826. ; SET ERRORLEVEL number
  1827. SETERL    PROC    NEAR
  1828.     mov    numhlp,offset erlhlp    ; help
  1829.     mov    numerr,0        ; error message
  1830.     mov    min,0            ; smallest number
  1831.     mov    max,255            ; largest magnitude
  1832.     call    num0            ; parse numerical input
  1833.     jc    seterl1            ; c = error
  1834.     mov    errlev,al        ; store result
  1835.     clc
  1836. seterl1:ret
  1837. SETERL    ENDP
  1838.  
  1839. ; SET ESCAPE character.
  1840. ; Accept literal control codes and \### numbers. [jrd] 18 Oct 1987
  1841. ESCSET    PROC    NEAR
  1842.     mov    ah,cmword
  1843.     mov    dx,offset rdbuf        ; work space
  1844.     mov    word ptr rdbuf,0    ; clear it
  1845.     mov    bx,offset eschlp    ; help
  1846.     call    comnd
  1847.     jc    escse2            ; c = failure
  1848.     or    ax,ax            ; anything given?
  1849.     jnz    escse1            ; nz = yes
  1850.     mov    dx,offset ermes6    ; more parameters needed
  1851.     jmp    reterr
  1852. escse1:    mov    ah,cmeol        ; get a confirm
  1853.     call    comnd
  1854.     jc    escse2            ; c = failure
  1855.     mov    si,offset rdbuf        ; source of chars
  1856.     call    katoi            ; convert escaped numbers to binary
  1857.     cmp    ax,spc            ; is it a control code?
  1858.     jae    escse3            ; ae = no, complain
  1859.     or    ax,ax            ; non-zero too?
  1860.     jz    escse3            ; z = zero
  1861.     mov    trans.escchr,al        ; save new escape char code
  1862.     clc
  1863. escse2:    ret
  1864. escse3:    mov    dx,offset escerr
  1865.     jmp    reterr
  1866. ESCSET    ENDP
  1867.  
  1868. ; SET FILE {DISPLAY, WARNING, TYPE, CHARACTER-SET}
  1869. SETFILE    proc    near
  1870.     mov    dx,offset setfitab    ; SET FILE table
  1871.     xor    bx,bx
  1872.     mov    ah,cmkey
  1873.     call    comnd
  1874.     jc    setfix            ; c = failure
  1875.     or    bl,bl            ; Warning?
  1876.     jnz    setfi1            ; nz = no
  1877.                     ; entry point for old SET WARNING
  1878. FILWAR:    mov    dx,offset warntab    ; warning table, on, off, no-super
  1879.     xor    bx,bx
  1880.     call    keyend
  1881.     jc    setfix            ; c = failure
  1882.     mov    flags.flwflg,bl        ; set the filewarning flag
  1883.     ret
  1884.  
  1885. setfi1:    cmp    bl,1            ; SET FILE CHARACTER-SET?
  1886.     jne    setfi2            ; ne = no
  1887.     mov    dx,offset setchtab    ; table of char sets
  1888.     xor    bx,bx
  1889.     call    keyend            ; get the set id
  1890.     jc    setfix            ; c = error
  1891.     mov    flags.chrset,bx        ; save the id
  1892.     cmp    bx,866            ; setting CP866?
  1893.     jne    setfi1a            ; ne = no
  1894.     cmp    dtrans.xchset,2        ; using TRANSFER of Cryillic?
  1895.     je    setfi1a            ; e = yes
  1896.     mov    dtrans.xchset,2        ; force TRANSFER of Cyrillic
  1897.     mov    trans.xchset,2
  1898.     mov    ah,prstr
  1899.     mov    dx,offset setchmsg    ; show warning
  1900.     int    dos
  1901. setfi1a:clc
  1902.     ret
  1903. setfi2:    cmp    bl,2            ; SET FILE TYPE?
  1904.     jne    setfi3            ; ne = 3
  1905.     mov    dx,offset xftyptab    ; table of types
  1906.     xor    bx,bx
  1907.     call    keyend
  1908.     jc    setfix            ; c = error
  1909.     mov    dtrans.xtype,bl        ; store transfer type
  1910.     mov    trans.xtype,bl        ; store transfer type
  1911.     ret
  1912. setfi3:    cmp    bl,3            ; SET FILE DISPLAY?
  1913.     jne    setfix            ; ne = no
  1914.     mov    dx,offset distab2    ; table
  1915.     xor    bx,bx
  1916.     call    keyend
  1917.     jc    setfix            ; c = failure
  1918.     and    flags.remflg,not(dquiet+dregular+dserial)
  1919.     or    flags.remflg,bl        ; set display mode
  1920.     clc
  1921. setfix:    ret
  1922. SETFILE    endp
  1923.  
  1924. ; SET FLOW-CONTROL {NONE, XONXOFF, RTS/CTS}
  1925.  
  1926. FLOSET    PROC    NEAR
  1927.     mov    dx,offset flotab
  1928.       xor    bx,bx
  1929.     call    keyend
  1930.     jc    floset3            ; c = failure
  1931.     mov    si,portval
  1932.     mov    ax,floxon        ; xon/xoff pair
  1933.     cmp    bx,1            ; using none or xon/xoff?
  1934.     jb    floset1            ; b = none
  1935.      je    floset2            ; e = xon/xoff
  1936.     cmp    flags.comflg,4        ; UART?
  1937.     ja    floset4            ; a = no, error
  1938. floset1:xor    ax,ax            ; clear chars for RTS/CTS and none
  1939. floset2:mov    [si].flowc,ax        ; flow control values
  1940.     mov    [si].floflg,bl        ; flow control kind
  1941.     call    serrst            ; reset port so opening uses above
  1942.     clc
  1943. floset3:ret
  1944. floset4:mov    dx,offset ermes7    ; error message
  1945.     jmp    reterr
  1946. FLOSET    ENDP
  1947.  
  1948. ; SET HANDSHAKE
  1949. ; Add ability to accept general decimal code.
  1950. HNDSET    PROC    NEAR
  1951.     mov    dx,offset hndtab    ; table to scan
  1952.     mov    bx,offset hnd1hlp    ; help message
  1953.     mov    ah,cmkey
  1954.     call    comnd
  1955.     jc    hnd2            ; c = failure
  1956.     cmp    bl,0ffh            ; want a general char code?
  1957.     jne    hnd1            ; ne = no
  1958.     mov    min,0            ; get decimal char code
  1959.     mov    max,31            ; range is 0 to 31 decimal
  1960.     mov    numhlp,offset ctlhlp    ; help message
  1961.     mov    numerr,0        ; error message
  1962.     call    num0            ; convert number, return it in ax
  1963.     jc    hnd2            ; c = error
  1964.     mov    bx,ax            ; recover numerical code
  1965. hnd1:    push    bx            ; handshake type
  1966.     mov    ah,cmeol
  1967.     call    comnd            ; get a confirm
  1968.     pop    bx            ; recover bx
  1969.     jc    hnd2            ; c = failure
  1970.     mov    si,portval
  1971.     or    bl,bl            ; setting handshake off?
  1972.     jz    hnd0            ; z = yes
  1973.     mov    [si].hndflg,1        ; turn on handshaking
  1974.     mov    [si].hands,bl        ; use this char as the handshake
  1975.     clc                ; success
  1976.     ret
  1977. hnd0:    mov    [si].hndflg,bl        ; no handshaking
  1978.     clc                ; success
  1979. hnd2:    ret
  1980. HNDSET    ENDP
  1981.  
  1982. ;   SET INCOMPLETE file disposition
  1983.  
  1984. ABFSET    PROC    NEAR
  1985.     mov    dx,offset abftab
  1986.     xor    bx,bx
  1987.     call    keyend
  1988.     jc    abfset1            ; c = failure
  1989.     mov    flags.abfflg,bl        ; Set the aborted file flag
  1990. abfset1:ret
  1991. ABFSET    ENDP
  1992. ;
  1993. ; Set Input commands (default-timeout, timeout-action, case, echo)
  1994. ; By Jim Strudevant [jrs]
  1995. INPSET    PROC    NEAR
  1996.     mov    ah,cmkey        ; key word
  1997.     mov    dx,offset inptab    ; from inputtable
  1998.     xor    bx,bx            ; no hints
  1999.     call    comnd            ; get the word
  2000.     jc    inpset1            ; c = failure
  2001.     jmp    bx            ; do the sub command
  2002. inpset1:ret
  2003. ;
  2004. ; Set Input Default-timeout in seconds
  2005. ;
  2006. inptmo:    mov    numhlp,offset intoms    ; help
  2007.     mov    numerr,0        ; error message
  2008.     mov    min,0            ; smallest number
  2009.     mov    max,-1            ; largest magnitude
  2010.     call    num0            ; parse numerical input
  2011.     jc    inptmo1            ; c = error
  2012.     mov    script.indfto,ax    ; store result
  2013. inptmo1:ret
  2014. ;
  2015. ; Set Input Timeout action (proceed or quit)
  2016. ;
  2017. inpact:    mov    dx,offset inactb    ; from this list
  2018.     xor    bx,bx            ; no hints
  2019.     call    keyend            ; get it
  2020.     jc    inpact1            ; c = failure
  2021.     mov    script.inactv,bl    ; save the action
  2022. inpact1:ret
  2023. ;
  2024. ; Set Input Echo on or off
  2025. ;
  2026. inpeco:    mov    dx,offset ontab        ; from this list
  2027.     xor    bx,bx            ; no hints
  2028.     call    keyend            ; get it
  2029.     jc    inpeco1            ; c = failure
  2030.     mov    script.inecho,bl    ; save the action
  2031. inpeco1:ret
  2032. ;
  2033. ; Set Input Case observe or ignore
  2034. ;
  2035. inpcas:    mov    dx,offset incstb    ; from this list
  2036.     xor    bx,bx            ; no hints
  2037.     call    keyend            ; get it
  2038.     jc    inpcas1            ; c = failure
  2039.     mov    script.incasv,bl    ; save the action
  2040. inpcas1:ret
  2041. INPSET    ENDP
  2042.  
  2043. ; Set length of script buffer for INPUT/REINPUT at Kermit initialization
  2044. ; time via Environment. Called by command parser while doing Environment
  2045. ; reading in mssker.asm. Do not call after Kermit has initialized.
  2046. SETINPBUF proc    near
  2047.     mov    scpbuflen,128        ; store default buffer length
  2048.     mov    numhlp,0        ; no help
  2049.     mov    numerr,0        ; no error message
  2050.     mov    min,2            ; smallest number (must be non-zero)
  2051.     mov    max,64535        ; largest magnitude (16 bits worth)
  2052.     call    num0            ; parse numerical input
  2053.     jc    setinpbx        ; c = error
  2054.     mov    scpbuflen,ax        ; store result
  2055.     clc
  2056. setinpbx:ret
  2057. SETINPBUF endp
  2058.  
  2059. ; SET KEY
  2060. ; Jumps to new Set Key routine
  2061. setkey    proc    near        
  2062.     cmp    stkadr,0    ; keyboard translator present?
  2063.     je    setk4        ; e = no, use this routine
  2064.     mov    bx,stkadr    ; yes, get offset of procedure
  2065.     jmp    bx        ; jump to keyboard translator
  2066. setk4:    mov    dx,offset ermes5
  2067.     jmp    reterr        ; else print error message
  2068. setkey    endp
  2069.  
  2070. ; SET LOCAL-ECHO {ON | OFF}
  2071.  
  2072. LCAL    PROC    NEAR
  2073.     mov    dx,offset ontab
  2074.     xor    bx,bx
  2075.     call    keyend
  2076.     jc    lcal1            ; c = failure
  2077.     mov    si,portval
  2078.     mov    [si].ecoflg,bl        ; Set the local echo flag
  2079. lcal1:    ret
  2080. LCAL    ENDP
  2081.  
  2082. ; LOG  {PACKETS | SESSION | TRANSACTION} filename
  2083.  
  2084. setcpt    proc    near
  2085.     mov    dx,offset logtab    ; kinds of logging
  2086.     mov    bx,offset loghlp    ; help on kind of logging
  2087.     mov    ah,cmkey        ; parse keyword
  2088.     call    comnd
  2089.     jnc    setcp20            ; nc = success
  2090.     ret                ; failure
  2091. setcp20:mov    numhlp,bx        ; save the parsed value
  2092.     mov    dx,offset rdbuf        ; holds the complete filename
  2093.     mov    rdbuf,0            ; clear buffer
  2094.     mov     bx,offset filhlp    ; ask for filename
  2095.     mov    ah,cmword        ; allow paths
  2096.     call    comnd
  2097.     jnc    setcp21            ; nc = success
  2098.     ret                ; failure
  2099. setcp21:mov    ah,cmeol
  2100.     call    comnd            ; get a confirm
  2101.     jnc    setcp22            ; nc = success
  2102.     ret                ; failure
  2103. setcp22:mov    bx,numhlp        ; recover kind of logging
  2104.     mov    dx,offset rdbuf        ; length of filename to cx
  2105.     call    strlen            ; length of given filename
  2106.     test    bl,logpkt        ; packet logging?
  2107.     jz    setcp2            ; z = no, try others
  2108.     mov    dx,offset lpktnam    ; filename
  2109.     jcxz    setcp1            ; z = no filename given
  2110.     mov    si,offset rdbuf        ; get new name
  2111.     mov    di,dx            ; destination
  2112.     call    strcpy            ; replace old name
  2113. setcp1:    cmp    ploghnd,-1        ; packet log file already open?
  2114.     je    setcp6            ; e = no, open it
  2115.     jmp    setcp16            ; say file is open already
  2116.  
  2117. setcp2:    test    bl,logses        ; session logging?
  2118.     jz    setcp4            ; z = no, try others
  2119.     mov    dx,offset lsesnam    ; use default name
  2120.     jcxz    setcp3            ; z = no filename given
  2121.     mov    si,offset rdbuf        ; get new name
  2122.     mov    di,dx            ; destination
  2123.     call    strcpy            ; replace old name
  2124. setcp3:    cmp    sloghnd,-1        ; transaction file already open?
  2125.     je    setcp6            ; e = no, open it
  2126.     jmp    setcp16            ; say file is open already
  2127.  
  2128. setcp4:    test    bl,logtrn        ; transaction logging?
  2129.     jz    setcp14            ; z = no, error
  2130.     mov    dx,offset ltranam    ; use default name
  2131.     jcxz    setcp5            ; z = no filename given
  2132.     mov    si,offset rdbuf        ; get new name
  2133.     mov    di,dx            ; destination
  2134.     call    strcpy            ; replace old name
  2135. setcp5:    cmp    tloghnd,-1        ; transaction file already open?
  2136.     je    setcp6            ; e = no, open it
  2137.     jmp    setcp16            ; say file is open already
  2138.  
  2139. setcp6:    mov    ax,dx            ; place for filename for isfile
  2140.     call    isfile            ; does file exist already?
  2141.     jc    setcp7            ; c = does not exist so use create
  2142.     test    byte ptr filtst.dta+21,1fh ; file attributes, ok to write?
  2143.     jnz    setcp14            ; nz = no, use error exit    
  2144.     mov    ah,open2        ; open existing file
  2145.     mov    al,1+1            ;  for writing and reading
  2146.     int    dos
  2147.     jc    setcp14            ; if carry then error
  2148.     mov    bx,ax            ; file handle for seeking
  2149.     xor    cx,cx            ; high order displacement
  2150.     xor    dx,dx            ; low order part of displacement
  2151.     mov    ah,lseek        ; seek to EOF (to do appending)
  2152.     mov    al,2            ; says to EOF
  2153.     int    dos
  2154.     jmp    short setcp8
  2155.  
  2156. setcp7:    test    filtst.fstat,80h    ; access problem?
  2157.     jnz    setcp14            ; nz = yes, stop here
  2158.     mov    ah,creat2        ; function is create
  2159.     mov    cx,20H            ; turn on archive bit
  2160.     int    dos            ; create the file, DOS 2.0
  2161.     jc    setcp14            ; if carry bit set then error
  2162.     mov    bx,ax            ; file handle
  2163.  
  2164. setcp8:    cmp    numhlp,logpkt        ; packet logging?
  2165.     jne    setcp9            ; ne = no
  2166.     mov    ploghnd,bx        ; save transaction log handle here
  2167.     jmp    short setcp12
  2168. setcp9:    cmp    numhlp,logses        ; session logging?
  2169.     jne    setcp10            ; ne = no
  2170.     mov    sloghnd,bx        ; save session log handle here
  2171.     jmp    short setcp12
  2172. setcp10:mov    tloghnd,bx        ; save transaction log handle here
  2173.  
  2174. setcp12:mov    ax,numhlp        ; kind of Logging
  2175.     or    flags.capflg,al        ; accumulate kinds of logging
  2176.     clc                ; success
  2177.     ret
  2178.  
  2179. setcp14:mov    dx,offset errcap    ; give error message
  2180.     jmp    reterr            ; and display it
  2181.  
  2182. setcp16:mov    ah,prstr        ; file already open
  2183.     mov    dx,offset erropn
  2184.     int    dos
  2185.     clc                ; return success
  2186.     ret
  2187. setcpt    endp
  2188.  
  2189. ; SET MODE LINE
  2190.  
  2191. MODL    PROC    NEAR
  2192.     mov    dx,offset ontab        ; parse an on or off
  2193.     xor    bx,bx            ; no special help
  2194.     call    keyend
  2195.     jc    modl1            ; c = failure
  2196.     mov    flags.modflg,bl        ; set flag appropriately
  2197. modl1:    ret
  2198. MODL    ENDP
  2199.  
  2200. ; SET PARITY
  2201.  
  2202. SETPAR    PROC    NEAR
  2203.     mov    dx,offset partab    ; parity table
  2204.     xor    bx,bx
  2205.     call    keyend
  2206.     jnc    setp1            ; nc = success
  2207.     ret
  2208. setp1:    mov    si,portval
  2209.     mov    [si].parflg,bl        ; store the parity flag
  2210.     call    serrst            ; reset port so opening uses above
  2211.     clc
  2212.     ret
  2213. SETPAR    ENDP
  2214.  
  2215. ; Set Print filename  for writing material to printers.
  2216. ; Puts filename in global string prnname
  2217. setprn    proc    near
  2218.     mov    dx,offset rdbuf        ; work area
  2219.     mov    rdbuf,0            ; clear it
  2220.     mov     bx,offset prnhlp    ; help message
  2221.     mov    ah,cmword        ; allow paths
  2222.     call    comnd
  2223.     jc    setprn3            ; c = failure
  2224.     mov    ah,cmeol
  2225.     call    comnd
  2226.     jc    setprn3            ; c = failure
  2227.     mov    dx,offset rdbuf        ; assume we will use this text
  2228.     call    strlen            ; filename given?
  2229.     mov    si,dx            ; for strcpy
  2230.     or    cx,cx            ; length of user's filename
  2231.     jg    setprn1            ; g = filename is given
  2232.     mov    si,offset prndefnam    ; no name, use default instead
  2233. setprn1:mov    di,offset prnname    ; copy to globally available loc
  2234.     call    strcpy
  2235.     cmp    prnhand,0        ; handle already in use?
  2236.     jle    setprn2            ; le = no
  2237.     call    pntflsh            ; flush current buffer
  2238.     mov    bx,prnhand        ; close the file now
  2239.     cmp    bx,4            ; don't close DOS PRN
  2240.     je    setprn2            ; e = already available
  2241.     mov    ah,close2
  2242.     int    dos
  2243. setprn2:call    prnopen            ; open printer now, may set carry
  2244.     jnc    setprn3            ; nc = success
  2245.     mov    ah,prstr
  2246.     mov    dx,offset prnerr    ; say can't open the file
  2247.     int    dos
  2248.     mov    si,offset prndefnam    ; use default name as fallback
  2249.     mov    di,offset prnname    ; copy to globally available loc
  2250.     call    strcpy
  2251.     mov    prnhand,4        ; declare handle to be DOS PRN
  2252. setprn3:ret
  2253. setprn    endp
  2254.  
  2255. ; SET PROMPT  Allow user to change the "Kermit-MS>" prompt
  2256. ; {string} and \number notation permitted to represent special chars.
  2257. ; String will be made asciiz
  2258.  
  2259. PROMSET    PROC    NEAR
  2260.     mov    ah,cmline
  2261.     mov    bx,offset rdbuf        ; Read in the prompt
  2262.     mov    word ptr [bx],0        ; clear buffer
  2263.     mov    dx,offset prmmsg
  2264.     call    comnd
  2265.     jc    prom2            ; c = failure
  2266.     or    ax,ax            ; prompt string?
  2267.     jnz    prom0            ; nz = yes
  2268.     mov    ax,offset kerm        ; no, restore default prompt
  2269.     jmp    short prom1
  2270. prom0:    push    si            ; parse \### constants into
  2271.     push    di            ;  1 byte binary numbers inline
  2272.     mov    si,offset rdbuf        ; source = new prompt string
  2273.     mov    byte ptr [si-1+length rdbuf],0 ; plant null terminator
  2274.     mov    di,offset prm        ; destination
  2275.     call    cnvlin            ; convert \### in string to binary
  2276.     pop    di
  2277.     pop    si
  2278.     mov    bx,cx            ; get byte count
  2279.     mov    prm[bx],0        ; insert null terminator
  2280.     mov    ax,offset prm
  2281. prom1:    mov    prmptr,ax        ; remember it
  2282.     clc                ; success
  2283. prom2:    ret
  2284. PROMSET    ENDP
  2285.  
  2286. ; SET SERVER {LOGIN username password | TIMEOUT}
  2287.  
  2288. SETSRV    PROC    NEAR
  2289.     mov    dx,offset srvtab    ; set server table
  2290.     xor    bx,bx            ; use table for help
  2291.     mov    ah,cmkey        ; get keyword
  2292.     call    comnd
  2293.     jnc    setsrv1            ; c = success
  2294.     ret
  2295. setsrv1:cmp    bl,1            ; Login?
  2296.     jne    setsrv2            ; ne = no
  2297.     test    flags.remflg,dserver    ; acting as a server now?
  2298.     jz    setsrv3            ; z = no
  2299.     stc                ; fail
  2300.     ret
  2301. setsrv3:mov    dx,offset rdbuf        ; where to store local username
  2302.     mov    bx,offset luserh    ; help
  2303.     mov    comand.cmblen,16    ; buffer length
  2304.     mov    ah,cmword        ; get username
  2305.     call    comnd
  2306.     jc    setsrvx
  2307.     mov    bx,offset rdbuf+30    ; where to store local password
  2308.     mov    dx,offset lpassh    ; help
  2309.     mov    comand.cmblen,16    ; buffer length
  2310.     mov    ah,cmline        ; get password, allow spaces
  2311.     call    comnd
  2312.     jc    setsrvx
  2313.     mov    si,offset rdbuf        ; only now do we transfer to the
  2314.     mov    di,offset luser        ; active buffers
  2315.     call    strcpy
  2316.     mov    si,offset rdbuf+30
  2317.     mov    di,offset lpass
  2318.     call    strcpy
  2319.     clc
  2320.     ret
  2321.  
  2322. setsrv2:mov    min,0            ; Timeout, smallest acceptable value
  2323.     mov    max,255            ; largest acceptable value, one byte
  2324.     mov    numhlp,offset srvthlp    ; help message
  2325.     mov    numerr,0        ; complaint message
  2326.     call    num0            ; parse numerical input
  2327.     jc    setsrvx            ; c = error
  2328.     mov    srvtmo,al        ; store timeout value
  2329.     clc                ; success
  2330. setsrvx:ret
  2331.     
  2332. SETSRV    ENDP
  2333.  
  2334. ; SET RETRY value. Changes the packet retry limit.
  2335.  
  2336. RETRYSET PROC    NEAR
  2337.     mov    min,1            ; smallest acceptable value
  2338.     mov    max,63            ; largest acceptable value
  2339.     mov    numhlp,offset retryhlp    ; help message
  2340.     mov    numerr,0        ; complaint message
  2341.     call    num0            ; parse numerical input
  2342.     jc    retrys1            ; c = error
  2343.     mov    maxtry,al
  2344. retrys1:ret
  2345. RETRYSET ENDP
  2346.  
  2347. ; Set number of screens in terminal emulator rollback buffer at Kermit
  2348. ; initialization time via Environment. Called by command parser while doing
  2349. ; Environment reading in mssker.asm. Do not call after Kermit has initialized.
  2350. SETROLLB proc    near
  2351.     mov    npages,10        ; default number of rollback screens
  2352.     mov    numhlp,0        ; no help
  2353.     mov    numerr,0        ; no error message
  2354.     mov    min,0            ; smallest number
  2355.     mov    max,130            ; largest magnitude (16 bits worth)
  2356.     call    num0            ; parse numerical input
  2357.     jc    setrol1            ; c = error
  2358.     mov    npages,ax        ; store result
  2359.     clc
  2360. setrol1:ret
  2361. SETROLLB endp
  2362.  
  2363.  
  2364. ; SET TAKE-ECHO     on or off
  2365.  
  2366. TAKSET    PROC    NEAR
  2367.     mov    dx,offset ontab
  2368.     xor    bx,bx
  2369.     call    keyend
  2370.     jc    takset1            ; c = failure
  2371.     mov    flags.takflg,bl
  2372. takset1:ret
  2373. TAKSET    ENDP
  2374.  
  2375. ; SET TIMER     on or off during file transfer
  2376.  
  2377. TIMSET    PROC    NEAR
  2378.     mov    dx,offset ontab
  2379.     xor    bx,bx
  2380.     call    keyend
  2381.     jc    timset1            ; c = failure
  2382.     mov    flags.timflg,bl
  2383. timset1:ret
  2384. TIMSET    ENDP
  2385.  
  2386. ; SET WINDOW number of windows
  2387. WINSET    PROC    NEAR
  2388.     mov    min,1            ; smallest acceptable value
  2389.     mov    max,maxwind        ; largest acceptable value
  2390.     mov    numhlp,offset winhelp    ; help message
  2391.     mov    numerr,0        ; complaint message
  2392.     call    num0            ; parse numerical input
  2393.     jc    winse5            ; c = error
  2394.     mov    dtrans.windo,al        ; store default window size
  2395.     mov    trans.windo,al        ; and in active variable for makebuf
  2396.     call    makebuf            ; clear old buffers
  2397.     cbw
  2398.     mov    cx,ax
  2399.     mov    ax,maxpack        ; length of main DATA buffer
  2400.     xor    dx,dx            ;   extended numerator
  2401.     cmp    cx,1            ; zero means one here
  2402.     jbe    winse1
  2403.     div    cx            ; get new max packet length into ax
  2404. winse1:    cmp    trans.slong,ax        ; need to shorten sent packets?
  2405.     jbe    winse2            ; be = no
  2406.     mov    trans.slong,ax        ; set send value
  2407.     mov    cl,dtrans.spsiz        ; default regular packet send size
  2408.     xor    ch,ch
  2409.     cmp    ax,cx            ; within normal packet range?
  2410.     ja    winse2            ; a = no
  2411.     mov    trans.spsiz,al        ; yes, update regular pkt size too
  2412. winse2:    cmp    trans.rlong,ax        ; need to shorten received pkts too?
  2413.     jbe    winse4            ; be = no
  2414.     mov    trans.rlong,ax        ; set receive value
  2415.     mov    cl,dtrans.rpsiz        ; default regular packet receive size
  2416.     xor    ch,ch
  2417.     cmp    ax,cx            ; within normal packet range?
  2418.     ja    winse4            ; a = no
  2419.     mov    trans.rpsiz,al        ; yes, update regular pkt size too
  2420. winse4:    clc                ; success
  2421. winse5:    ret
  2422. WINSET    ENDP
  2423.  
  2424. ; SET SEND parameters
  2425.  
  2426. SENDSET    PROC    NEAR
  2427.     mov    stflg,'S'        ; Setting SEND parameter 
  2428.     mov    dx,offset stsrtb    ; Parse a keyword
  2429.     xor    bx,bx            ; no specific help
  2430.     mov    ah,cmkey
  2431.     call    comnd
  2432.     jc    sendset1        ; c = failure
  2433.     jmp    bx            ; do the action routine
  2434. sendset1:ret
  2435. SENDSET    ENDP
  2436.  
  2437. ; SET RECEIVE parameters
  2438.  
  2439. recset:    mov    stflg,'R'        ; Setting RECEIVE paramter
  2440.     mov    dx,offset stsrtb    ; Parse a keyword
  2441.     xor    bx,bx            ; no specific help
  2442.     mov    ah,cmkey
  2443.     call    comnd
  2444.     jc    recset1            ; c = failure
  2445.     jmp    bx            ; do the action routine
  2446. recset1:ret
  2447.  
  2448. remset    proc    near            ; Set REMOTE ON/OFF
  2449.     mov    dx,offset ontab
  2450.     mov    bx,offset remhlp
  2451.     call    keyend
  2452.     jc    remset2            ; c = failure
  2453.     and    flags.remflg,not (dquiet+dserial+dregular) ; no display bits
  2454.     or    bl,bl            ; want off state? (same as regular)
  2455.     jz    remset1            ; z = yes
  2456.     or    flags.remflg,dquiet    ; else on = quiet display
  2457.     clc
  2458.     ret
  2459. remset1:or    flags.remflg,dregular    ; off = regular display
  2460.     clc
  2461. remset2:ret
  2462. remset    endp
  2463.  
  2464.  
  2465. ; SET Send and Receive End-of-Packet char
  2466.  
  2467. sreol    PROC    NEAR
  2468.     mov    min,0            ; lowest acceptable value
  2469.     mov    max,1FH            ; largest acceptable value
  2470.     mov    numhlp,offset ctlhlp    ; reuse help message
  2471.     mov    numerr,0        ; error message address
  2472.     call    num0            ; get numerical input
  2473.     jc    sreol3            ; c = error
  2474.     cmp    stflg,'S'        ; setting SEND paramter?
  2475.     je    sreol1
  2476.     mov    trans.reol,al
  2477.     jmp    short sreol2
  2478. sreol1:    mov    dtrans.seol,al
  2479. sreol2:    mov    ah,dtrans.seol
  2480.     mov    trans.seol,ah
  2481.     clc
  2482. sreol3:    ret
  2483. sreol    ENDP
  2484.  
  2485.  
  2486. ; SET SEND and RECEIVE start-of-header
  2487.  
  2488. srsoh:    mov    min,0
  2489.     mov    max,1FH
  2490.     mov    numhlp,offset ctlhlp    ; Reuse help message
  2491.     mov    numerr,0        ; error message
  2492.     call    num0        ; Common routine for parsing numerical input
  2493.     jc    srsoh2            ; c = error
  2494.     cmp    stflg,'S'        ; Setting SEND paramter?
  2495.     je    srsoh1
  2496.     mov    trans.rsoh,al        ; set Receive soh
  2497.     clc                ; success
  2498.     ret
  2499. srsoh1:    mov    trans.ssoh,al        ; set Send soh
  2500.     clc                ; success
  2501.     ret
  2502. srsoh2:    ret
  2503.  
  2504. ; SET Send Double-char
  2505.  
  2506. srdbl    PROC    NEAR
  2507.     mov    min,0            ; lowest acceptable value
  2508.     mov    max,0ffh        ; largest acceptable value
  2509.     mov    numhlp,offset dblhlp    ; help
  2510.     mov    numerr,0        ; error message address
  2511.     call    num0            ; get numerical input
  2512.     jc    sreol3            ; c = error
  2513.     cmp    stflg,'R'        ; setting Receive paramter?
  2514.     je    srdbl1            ; e = yes, no action
  2515.     mov    trans.sdbl,al        ; store character to be doubled
  2516.     mov    dtrans.sdbl,al
  2517.     clc
  2518. srdbl1:    ret
  2519. srdbl    ENDP
  2520.  
  2521. ; SET Receive Ignore-char
  2522.  
  2523. srign    PROC    NEAR
  2524.     mov    min,0            ; lowest acceptable value
  2525.     mov    max,0ffh        ; largest acceptable value
  2526.     mov    numhlp,offset dblhlp    ; reuse help
  2527.     mov    numerr,0        ; error message address
  2528.     call    num0            ; get numerical input
  2529.     jc    srign1            ; c = error
  2530.     cmp    stflg,'S'        ; setting SEND paramter?
  2531.     je    srign1            ; e = yes, no action
  2532.     mov    trans.rign,al        ; store character to be ignored
  2533.     mov    dtrans.rign,al
  2534.     clc
  2535. srign1:    ret
  2536. srign    ENDP
  2537.  
  2538. ; SET SEND and    RECEIVE TIMEOUT
  2539.  
  2540. srtim:    mov    min,0
  2541.     mov    max,94
  2542.     mov    numhlp,offset timhlp    ; Reuse help message
  2543.     mov    numerr,0        ; error message
  2544.     call    num0        ; Common routine for parsing numerical input
  2545.     jc    srtim3            ; c = error
  2546.     cmp    stflg,'S'        ; Setting SEND paramter?
  2547.     je    srtim1
  2548.     mov    trans.rtime,al
  2549.     jmp    short srtim2
  2550. srtim1:    mov    dtrans.stime,al
  2551. srtim2:    mov    ah,dtrans.stime
  2552.     mov    trans.stime,ah
  2553.     clc
  2554. srtim3:    ret
  2555.  
  2556. ; SET SEND and RECEIVE PACKET LENGTH
  2557. ; dtrans items are real, trans items are just for SHOW information
  2558.  
  2559. srpack:    mov    min,20
  2560.     mov    max,maxpack
  2561.     mov    numhlp,offset pakhlp    ; help
  2562.     mov    numerr,offset pakerr    ; error message
  2563.     call    num0
  2564.     jnc    srpaks0            ; nc = success
  2565.     ret                ; failure
  2566. srpaks0:cmp    stflg,'S'        ; setting send value?
  2567.     jne    srpakr            ; ne = receive
  2568.     mov    dtrans.slong,ax        ; set send max value
  2569.     mov    trans.slong,ax        ; store current active length
  2570.     mov    dtrans.spsiz,dspsiz    ; set regular 94 byte default
  2571.     cmp    ax,dspsiz        ; longer than regular packet?
  2572.     jae    srpaks1            ; ae = yes
  2573.     mov    dtrans.spsiz,al        ; shrink regular packet size too
  2574.     mov    trans.spsiz,al        ; shrink regular packet size too
  2575. srpaks1:mov    ax,maxpack        ; maximum buffer size
  2576.     xor    dx,dx
  2577.     mov    cl,dtrans.windo        ; current window slots
  2578.     xor    ch,ch
  2579.     div    cx            ; get active send packet length
  2580.     cmp    ax,dtrans.slong        ; longer than user specified?
  2581.     jae    srpaks4            ; ae = yes, employ user limit
  2582.     mov    cl,dtrans.spsiz        ; regular packet length
  2583.     xor    ch,ch
  2584.     cmp    ax,cx            ; windowed shorter than normal packet?
  2585.     jae    srpaks3            ; ae = no
  2586.     mov    trans.spsiz,al        ; shrink regular pkt size
  2587.     xor    ah,ah
  2588. srpaks3:mov    trans.slong,ax        ; store current active length
  2589. srpaks4:clc                ; success
  2590.     ret
  2591.  
  2592. srpakr:    mov    dtrans.rlong,ax        ; set receive max value
  2593.     mov    trans.rlong,ax        ; store active length
  2594.     mov    dtrans.rpsiz,drpsiz    ; set regular to default 94 bytes
  2595.     mov    trans.rpsiz,drpsiz
  2596.     cmp    ax,drpsiz        ; longer than a regular packet?
  2597.     jae    srpakr1            ; ae = yes
  2598.     mov    dtrans.rpsiz,al        ; shrink regular packet size too
  2599.     mov    trans.rpsiz,al
  2600. srpakr1:mov    ax,maxpack        ; maximum buffer size
  2601.     xor    dx,dx
  2602.     mov    cl,dtrans.windo        ; current window slots
  2603.     xor    ch,ch
  2604.     div    cx            ; get fully windowed packet length
  2605.     cmp    ax,dtrans.rlong        ; longer than user specified?
  2606.     jae    srpakr4            ; ae = yes, employ user limit
  2607.     mov    cl,dtrans.rpsiz        ; regular packet length
  2608.     xor    ch,ch
  2609.     cmp    ax,cx            ; windowed shorter than normal packet?
  2610.     jae    srpakr3            ; ae = no
  2611.     mov    trans.rpsiz,al        ; shrink regular packet length
  2612.     xor    ah,ah
  2613. srpakr3:mov    trans.rlong,ax        ; store active length
  2614. srpakr4:clc                ; success
  2615.     ret
  2616.  
  2617.  
  2618. ; SET SEND and RECEIVE number of padding characters
  2619.  
  2620. srnpd:    mov    min,0
  2621.     mov    max,94
  2622.     mov    numhlp,offset timhlp    ; reuse help message
  2623.     mov    numerr,0        ; error message
  2624.     call    num0            ; Parse numerical input
  2625.     jc    srnpd3            ; c = error
  2626.     cmp    stflg,'S'        ; Setting SEND paramter?
  2627.     je    srnpd1            ; e = yes
  2628.     mov    trans.rpad,al        ; set Receive padding
  2629.     jmp    short srnpd2
  2630. srnpd1:    mov    dtrans.spad,al        ; set default Send padding
  2631. srnpd2:    mov    al,dtrans.spad
  2632.     mov    trans.spad,al        ; update active array for I and S pkts
  2633.     clc
  2634. srnpd3:    ret
  2635.  
  2636. ; SET SEND and RECEIVE padding character
  2637.  
  2638. srpad:    mov    min,0
  2639.     mov    max,127
  2640.     mov    numhlp,offset padhlp
  2641.     mov    numerr,offset padhlp
  2642.     call    num0            ; parse numerical input
  2643.     jc    srpad4            ; c = error
  2644.     cmp    ah,127            ; this is allowed
  2645.     je    srpad1
  2646.     cmp    ah,32
  2647.     jb    srpad1            ; between 0 and 31 is OK too
  2648.     mov    ah,prstr
  2649.     mov    dx,offset padhlp
  2650.     int    dos
  2651. srpad1:    cmp    stflg,'S'        ; Send?
  2652.     je    srpad2            ; e = yes, else Receive
  2653.     mov    trans.rpadch,al        ; store receive pad char
  2654.     jmp    short srpad3
  2655. srpad2:    mov    dtrans.spadch,al    ; store Send pad char
  2656. srpad3:    mov    ah,dtrans.spadch
  2657.     mov    trans.spadch,ah      ; update active array for I and S pkts
  2658.     clc                ; success
  2659. srpad4:    ret
  2660.  
  2661. ; SET SEND and    RECEIVE control character prefix
  2662.  
  2663. srquo:    mov    min,33
  2664.     mov    max,126
  2665.     mov    numhlp,offset quohlp    ; help message
  2666.     mov    numerr,0        ; error message
  2667.     call    num0            ; Parse numerical input
  2668.     jc    srquo3            ; c = error
  2669.     cmp    stflg,'S'        ; Setting outgoing quote char?
  2670.     je    srquo1            ; e = yes
  2671.     mov    trans.rquote,al        ; set Receive quote char
  2672.     jmp    short srquo2
  2673. srquo1:    mov    dtrans.squote,al    ; set Send quote char
  2674. srquo2:    clc
  2675. srquo3:    ret
  2676.  
  2677. ; SET SEND Pause number    of milliseconds
  2678.  
  2679. srpaus:    mov    min,0
  2680.     mov    max,127
  2681.     mov    numhlp,offset pauhlp    ; help
  2682.     mov    numerr,0
  2683.     call    num0            ; Parse numerical input
  2684.     pushf                ; save carry for error state
  2685.     cmp    stflg,'S'        ; Setting SEND paramter?
  2686.     je    srpau0
  2687.     popf
  2688.     mov    dx,offset ermes5    ; "Not implemented" msg
  2689.     jmp    reterr            ; print error message
  2690. srpau0:    popf
  2691.     jc    srpau1            ; c = error
  2692.     mov    spause,al        ; store value
  2693. srpau1:    ret
  2694.  
  2695. ; SET TCP/IP address nnn.nnn.nnn.nnn
  2696. ; SET TCP/IP subnetmask nnn.nnn.nnn.nnn
  2697. ; SET TCP/IP gateway nnn.nnn.nnn.nnn
  2698. ; SET TCP/IP primary-nameserver nnn.nnn.nnn.nnn
  2699. ; SET TCP/IP secondary-nameserver nnn.nnn.nnn.nnn
  2700. ; SET TCP/IP domain string
  2701.  
  2702. tcpipset proc    near
  2703.     mov    ah,cmkey        ; get keyword
  2704.     mov    dx,offset tcptable    ; table
  2705.     xor    bx,bx            ; help
  2706.     call    comnd
  2707.     jnc    tcpse1
  2708.     ret
  2709. tcpse1:    mov    word ptr rdbuf,bx    ; keyword index
  2710.     cmp    bx,1            ; local address help?
  2711.     jne    tcpse1a            ; ne = no
  2712.     mov    bx,offset addrhelp    ; address help
  2713.     jmp    short tcpse4
  2714. tcpse1a:cmp    bx,2            ; domain name?
  2715.     jne    tcpse2            ; ne = no
  2716.     mov    bx,offset domainhlp    ; domain help
  2717.     jmp    short tcpse4
  2718. tcpse2:    cmp    bx,6            ; subnet mask?
  2719.     jne    tcpse3            ; ne = no
  2720.     mov    bx,offset subnethlp
  2721.     jmp    short tcpse4
  2722. tcpse3:    cmp    bx,7            ; Host?
  2723.     jne    tcpse3a            ; ne = no
  2724.     mov    bx,offset hosthlp
  2725.     jmp    short tcpse4
  2726. tcpse3a:mov    bx,offset iphelp    ; Internet number help
  2727. tcpse4:    mov    ah,cmword        ; get a string
  2728.     mov    dx,offset rdbuf+2    ; work buffer
  2729.     call    comnd
  2730.     jnc    tcpse5
  2731.     ret
  2732. tcpse5:    push    ax            ; save string length in ax
  2733.     mov    ah,cmeol
  2734.     call    comnd
  2735.     pop    ax
  2736.     jnc    tcpse6
  2737.     ret
  2738. tcpse6:    mov    si,offset rdbuf+2    ; user's string
  2739.     mov    bx,word ptr rdbuf    ; comand kind
  2740.     cmp    bx,2            ; domain?
  2741.     jne    tcpse8            ; ne = no
  2742.     mov    di,offset tcpdomain
  2743.     cmp    ax,32            ; exceeded 32 chars?
  2744.     jbe    tcpse7            ; be = no
  2745.     mov    ah,prstr
  2746.     mov    dx,offset domainbad    ; compain
  2747.     int    dos
  2748.     stc
  2749.     ret
  2750. tcpse7:    cmp    ax,32            ; address oversized?
  2751.     jbe    tcpse9            ; be = no
  2752.     mov    ah,prstr
  2753.     mov    dx,offset addressbad    ; say bad address
  2754.     int    dos
  2755.     stc
  2756.     ret
  2757. tcpse8:    mov    di,offset tcpaddress
  2758.     cmp    bx,1            ; local address?
  2759.     je    tcpse9            ; e = yes
  2760.     mov    di,offset tcpsubnet
  2761.     cmp    bx,3            ; subnet?
  2762.     je    tcpse9            ; e = yes
  2763.     mov    di,offset tcpgateway
  2764.     cmp    bx,4            ; gateway?
  2765.     je    tcpse9
  2766.     mov    di,offset tcpprimens
  2767.     cmp    bx,5            ; primary-nameserver?
  2768.     je    tcpse9
  2769.     mov    di,offset tcpsecondns    ; secondary-nameserer
  2770.     cmp    bx,6
  2771.     je    tcpse9
  2772.     mov    di,offset tcphost    ; host name or number
  2773.     cmp    bx,7
  2774.     je    tcpse9
  2775.     mov    di,offset tcpbcast    ; broadcast
  2776. tcpse9:    call    strcpy
  2777.     clc
  2778.     ret
  2779. tcpipset endp
  2780.  
  2781. ; SET TRANSFER  CHARACTER-SET {Latin1, Transparent}
  2782. sxfer    proc    near
  2783.     mov    dx,offset xfertab    ; table of TRANSFER keywords
  2784.     xor    bx,bx
  2785.     mov    ah,cmkey        ; get next keyword
  2786.     call    comnd
  2787.     jc    sxfer1            ; c = error
  2788.     or    bl,bl            ; Character-set?
  2789.     jnz    sxfer1            ; nz = no
  2790.     mov    dx,offset xfchtab    ; Character-set table
  2791.     mov    bx,offset xfchhlp    ; help text
  2792.     call    keyend
  2793.     jc    sxfer1            ; c = error
  2794.     mov    dtrans.xchset,bl    ; store transfer char set ident
  2795.     mov    trans.xchset,bl        ; store transfer char set ident
  2796.     cmp    bl,2            ; Cyrillic?
  2797.     jne    sxfer1            ; ne = no
  2798.     mov    ax,flags.chrset        ; get current file character set
  2799.     mov    flags.chrset,866    ; force CP866
  2800.     cmp    ax,866            ; was CP866/LATIN5 File Character set?
  2801.     jne    sxfer2            ; ne = no, show warning about force
  2802.     clc
  2803. sxfer1:    ret
  2804. sxfer2:    mov    dx,offset xfchbad    ; show warning message
  2805.     mov    ah,prstr
  2806.     int    dos
  2807.     clc
  2808.     ret
  2809. sxfer    endp
  2810.  
  2811. ; SET TRANSLATION           Connect mode translate characters
  2812. ; SET TRANSLATION INPUT {Original-byte New-byte | ON | OFF}
  2813. ; SET TRANSLATION KEYBOARD {ON | OFF}, default is ON
  2814.  
  2815. SETRX    PROC    NEAR            ; translate incoming serial port char
  2816.     mov    ah,cmkey
  2817.     mov    dx,offset trnstab    ; direction table (just one entry)
  2818.     xor    bx,bx            ; no help
  2819.     call    comnd
  2820.     jnc    setrx0            ; nc = success
  2821.     ret                ; failure
  2822. setrx0:    cmp    bx,2            ; Keyboard?
  2823.     jne    setrx0b            ; ne = no
  2824.     jmp    setr11            ; do keyboard
  2825. setrx0b:mov    dx,offset rdbuf        ; our work space
  2826.     mov    word ptr rdbuf,0    ; insert terminator
  2827.     mov    bx,offset srxhlp1    ; first help message
  2828.     mov    ah,cmword        ; parse a word
  2829.     call    comnd            ; get incoming byte pattern
  2830.     jnc    setrx0a            ; nc = success
  2831.     ret
  2832. setrx0a:or    ax,ax            ; any text given?
  2833.     jz    setr6            ; nz = no
  2834.     mov    temp,ax            ; save byte count here
  2835.     mov    ax,word ptr rdbuf    ; get first two characters
  2836.     or    ax,2020h        ; convert upper to lower case
  2837.     cmp    ax,'fo'            ; first part of word OFF?
  2838.     je    setr6            ; e = yes, go analyze
  2839.     cmp    ax,'no'            ; word ON?
  2840.     je    setr6            ; e = yes, go do it
  2841.     mov    si,offset rdbuf        ; convert text to number
  2842.     call    katoi            ; number converter procedure, to ax
  2843.     jnc    setr1            ; nc = success    
  2844.     cmp    temp,1            ; just one character given?
  2845.     jne    setr6            ; ne = no, so bad code
  2846. setr1:    mov    min,ax            ; save byte code here
  2847.     mov    dx,offset rdbuf        ; our work space
  2848.     mov    word ptr rdbuf,0    ; insert terminator
  2849.     mov    bx,offset srxhlp1    ; first help message
  2850.     mov    ah,cmword        ; parse a word
  2851.     call    comnd            ; get incoming byte pattern
  2852.     jnc    setr2            ; nc = success
  2853.     ret                ; failure
  2854. setr2:    or    ax,ax            ; any text given?
  2855.     jz    setr6            ; z = no
  2856.     mov    temp,ax            ; save byte count here
  2857.     mov    si,offset rdbuf        ; convert text to number
  2858.     call    katoi            ; number converter procedure
  2859.     jnc    setr3            ; nc = success
  2860.     cmp    temp,1            ; just one character given?
  2861.     jne    setr6            ; ne = no, so bad code or ON/OFF
  2862. setr3:    mov    max,ax            ; save byte code here
  2863.     mov    ah,cmeol        ; get a confirm
  2864.     call    comnd
  2865.     jnc    setr3a            ; nc = success
  2866.     ret                ; failure
  2867. setr3a:    mov    bx,min            ; bl = incoming byte code
  2868.     xor    bh,bh
  2869.     mov    ax,max            ; al = local (translated) byte code
  2870.     mov    rxtable [bx],al        ; store in rx translate table
  2871.     clc                ; success
  2872.     ret
  2873.  
  2874. setr6:    mov    ah,cmeol        ; get a confirm
  2875.     call    comnd
  2876.     jnc    setr6a            ; nc = success
  2877.     ret                ; failure
  2878. setr6a:    mov    dx,offset badrx        ; assume bad construction
  2879.     or    word ptr rdbuf,2020h    ; convert to lower case
  2880.     or    rdbuf+2,20h        ; first three chars
  2881.     cmp    word ptr rdbuf,'fo'    ; key word OFF?
  2882.     jne    setr8            ; ne = no
  2883.     cmp    rdbuf+2,'f'        ; last letter of OFF?
  2884.     jne    setr8            ; ne = no
  2885.     mov    rxtable+256,0        ; OFF is status byte = zero
  2886.     mov    dx,offset rxoffmsg    ; say translation is turned off
  2887.     jmp    short setr9
  2888. setr8:    cmp    word ptr rdbuf,'no'    ; keyword ON?
  2889.     jne    setr9a            ; ne = no, error
  2890.     mov    rxtable+256,1        ; ON is status byte non-zero
  2891.     mov    dx,offset rxonmsg    ; say translation is turned on
  2892. setr9:    cmp    taklev,0        ; executing from a Take file?
  2893.     je    setr9a            ; e = no
  2894.     cmp    flags.takflg,0        ; echo contents of Take file?
  2895.     je    setr10            ; e = no
  2896. setr9a:    mov    ah,prstr        ; bad number message
  2897.     int    dos
  2898. setr10:    clc
  2899.     ret
  2900. setr11:    mov    ah,cmkey        ; SET TRANSLATION KEYBOARD
  2901.     mov    dx,offset ontab        ; on/off
  2902.     xor    bx,bx
  2903.     call    comnd
  2904.     jnc    setr12            ; nc = success
  2905.     ret
  2906. setr12:    mov    ah,cmeol        ; get a confirm
  2907.     call    comnd
  2908.     jnc    setr13            ; nc = success
  2909.     ret                ; failure
  2910. setr13:    mov    flags.xltkbd,bl        ; set keyboard translation on/off
  2911.     clc
  2912.     ret
  2913. SETRX    ENDP
  2914.  
  2915. ; SET TRANSMIT {FILL, LF, Prompt} {ON, OFF, or value}
  2916. SETXMIT    proc    near
  2917.     mov    dx,offset xmitab    ; TRANSMIT keyword table
  2918.     xor    bx,bx
  2919.     mov    ah,cmkey        ; get keyword
  2920.     call    comnd
  2921.     jnc    setxmi1            ; nc = success
  2922.     ret
  2923. setxmi1:cmp    bl,2            ; SET TRANSMIT PROMPT?
  2924.     jne    setxmi2            ; ne = no
  2925.     mov    ah,cmword
  2926.     mov    dx,offset rdbuf+1    ; put answer here
  2927.     mov    bx,offset xpmthlp
  2928.     call    comnd
  2929.     jc    setxmi1d        ; c = error
  2930.     push    ax            ; save length
  2931.     mov    ah,cmeol        ; get a confirm
  2932.     call    comnd
  2933.     pop    cx            ; recover length to cx
  2934.     jc    setxmi1d        ; c = failure
  2935.     mov    al,rdbuf+1
  2936.     cmp    cx,1            ; a single char?
  2937.     je    setxmi1c        ; e = yes, use it as the prompt char
  2938.     mov    si,offset rdbuf+1
  2939.     cmp    byte ptr [si],'\'    ; already quoted?
  2940.     je    setxmi1b        ; e = yes
  2941.     mov    rdbuf,'\'        ; add a numerical quote
  2942.     dec    si            ; point to our escape char
  2943. setxmi1b:call    katoi            ; convert number in rdbuf
  2944.     jc    setxmi1d        ; c = no number, error
  2945. setxmi1c:mov    script.xmitpmt,al    ; store new prompt value
  2946. setxmi1d:ret
  2947.  
  2948. setxmi2:cmp    bl,1            ; LF?
  2949.     jne    setxmi3            ; ne = no
  2950.     mov    dx,offset ontab        ; on or off table
  2951.     xor    bx,bx
  2952.     call    keyend
  2953.     jc    setxmix            ; c = failure
  2954.     mov    script.xmitlf,bl    ; set the xmitlf flag
  2955.     ret
  2956.  
  2957. setxmi3:mov    ah,cmword        ; FILL, get a word sized token
  2958.     mov    dx,offset rdbuf+1    ; put it here
  2959.     mov    bx,offset xfilhlp    ; help
  2960.     call    comnd
  2961.     jc    setxmix            ; c = failure
  2962.     push    ax            ; save length in ah
  2963.     mov    ah,cmeol        ; get a confirm
  2964.     call    comnd
  2965.     pop    ax
  2966.     jc    setxmix            ; c = failure
  2967.     cmp    ax,1            ; just one character?
  2968.     ja    setxmi4            ; a = no, there's more
  2969.     mov    al,rdbuf+1        ; get the char
  2970.     mov    script.xmitfill,al    ; store Fill char
  2971.     ret
  2972. setxmi4:mov    ax,word ptr rdbuf+1
  2973.     or    ax,2020h        ; to lower
  2974.     cmp    ax,'on'            ; "none"?
  2975.     jne    setxmi5            ; ne = no
  2976.     mov    script.xmitfill,0    ; no Filling
  2977.     ret
  2978. setxmi5:cmp    ax,'ps'            ; "space"?
  2979.     jne    setxmi6            ; ne = no
  2980.     mov    script.xmitfill,' '    ; use space as filler
  2981.     ret
  2982. setxmi6:mov    si,offset rdbuf+1
  2983.     cmp    byte ptr [si],'\'    ; already quoted?
  2984.     je    setxmi7            ; e = yes
  2985.     mov    rdbuf,'\'        ; add a numerical quote
  2986.     dec    si            ; point to our escape char
  2987. setxmi7:call    katoi            ; convert number in rdbuf
  2988.     jc    setxmix            ; c = no number, error
  2989.     mov    script.xmitfill,al    ; set the xmitfill flag
  2990. setxmix:ret
  2991. SETXMIT    endp
  2992.  
  2993. ; SET UNKNOWN-CHARACTER-SET {DISCARD, KEEP}, default is KEEP
  2994. unkchset proc    near
  2995.     mov    dx,offset unkctab    ; keep/reject keyword table
  2996.     mov    bx,offset unkchhlp
  2997.     call    keyend
  2998.     jc    unkchx            ; c = failure
  2999.     mov    flags.unkchs,bl        ; 0 = keep, else reject
  3000. unkchx:    ret
  3001. unkchset endp
  3002.  
  3003. ; Common routine for parsing numerical input
  3004. ; Enter with numhlp = offset of help message, numerr = offset of optional
  3005. ;  error message, min, max = allowable range of values.
  3006. ; Returns value in ax, or does parse error return.
  3007. ; Changes ax,bx,dx,si.            [jrd] 18 Oct 1987
  3008. num0:    mov    dx,offset rdbuf+1    ; were to put text
  3009.     mov    word ptr rdbuf,0    ; clear the buffer
  3010.     mov    bx,numhlp        ; help text
  3011.     mov    ah,cmword        ; get a word
  3012.     call    comnd
  3013.     jc    num0x            ; c = failure
  3014.     mov    ah,cmeol
  3015.     call    comnd            ; Get a confirm
  3016.     jc    num0x            ; c = failure
  3017.                     ; second entry point
  3018. numwd:    mov    si,offset rdbuf+1
  3019.     cmp    rdbuf+1,'\'        ; already quoted?
  3020.     je    num0a            ; e = yes
  3021.     mov    rdbuf,'\'        ; add a numerical quote
  3022.     dec    si            ; point to our escape char
  3023. num0a:    call    katoi            ; convert number in rdbuf
  3024.     jc    num0er            ; c = no number, error
  3025.     cmp    ax,max            ; largest permitted value
  3026.     ja    num0er            ; a = error
  3027.     cmp    ax,min            ; smallest permitted value
  3028.     jb    num0er            ; b = error
  3029.     clc
  3030. num0x:    ret                ; return value in ax
  3031.  
  3032. num0er:    mov    ah,prstr
  3033.     mov    dx,numerr        ; comand-specific error message, if any
  3034.     or    dx,dx            ; was any given?
  3035.     jz    num0e1            ; z = no, use generic msg
  3036.     int    dos            ; show given error message
  3037.     jmp    short num0e2
  3038. num0e1:    mov    dx,offset nummsg1    ; get address of numeric error message
  3039.     int    dos
  3040.     mov    ax,min            ; smallest permitted number
  3041.     call    decout            ; display decimal number in ax
  3042.     mov    ah,prstr
  3043.     mov    dx,offset nummsg2    ; "and"
  3044.     int    dos
  3045.     mov    ax,max            ; largest permitted number
  3046.     call    decout
  3047.     mov    ah,prstr
  3048.     mov    dx,offset crlf
  3049.     int    dos
  3050. num0e2:    stc
  3051.     ret
  3052.  
  3053. ; routine to print an error message, then exit without error status
  3054. ; expects message in dx
  3055. reterr    proc    near
  3056.     mov    ah,prstr
  3057.     int    dos
  3058.     clc
  3059.     ret
  3060. reterr    endp
  3061.  
  3062. code    ends
  3063.     end
  3064.